       currentDialogPr = null
       dialog.remove()
       cancelLock()
+      originalFocusedElement.focus()
 
 
   ns.openPreviewDialog = (file, settings) ->


  ns.openDialog = (files, tab, settings) ->
    ns.closeDialog()

    dialog = $(tpl('dialog')).appendTo('body')
    dialogPr = ns.openPanel(dialog.find('.uploadcare--dialog__placeholder'),

    dialog.addClass('uploadcare--dialog_status_active')
    dialogPr.dialogElement = dialog

    focusableElements = dialog.find('select, input, textarea, button, a[href]')
    focusableElements.first().focus()

    cancelLock = lockScroll($(window), dialog.css('position') is 'absolute')
    $('html, body').addClass(openedClass)

