Search code examples
dialogwindowelectronfileopendialog

Electron: File dialog window should be focused until decision


How to force the file dialog window to be always open on the top until the user choose a file or closes the window? The user should not be able to navigate to other windows in the application.


Solution

  • I found the solution in the docs https://github.com/electron/electron/blob/master/docs/api/dialog.md#dialogshowopendialogbrowserwindow-options-callback

    The dialog should be set to modal. If the window is modal it disables the parent window. It can be set to modal with passing browserWindow parameter as first argument when calling showSaveDialog function.

    Excepted format:

    dialog.showOpenDialog([browserWindow, ]options[, callback])