nw.js
nw.js copied to clipboard
Missing "Create Folder" button in nwdirectory dialog windows
NWJS Version : 0.55.0 Operating System : Linux (Ubuntu 20.04)
Expected behavior
When using an nwdirectory input, the directory selection dialog window should allow creating a new directory/folder.
Actual behavior
The directory selection dialog window only allows selecting existing directories.
How to reproduce
Click on an nwdirectory input element and note that there is no button or any other mechanism to create a new directory.
Comments
It appears that the wrong flags are simply being selected when creating the dialog window. Some examples:
- When running
zennity --file-selection --directory, the dialog window has a Create Folder button. - The "Save As..." dialog in Chromium DevTools within NW.js has a Create Folder button.
- The "Save As..." dialog window in Chrome has a Create Folder button.
So, the dialog is capable of showing the button, NW.js just needs to make it happen when nwdirectory is being used.
NW.js nwdirectory Dialog

zennity --file-selection --directory Dialog

Note the Create Folder button near the top-right corner.
Related: https://magpcss.org/ceforum/apidocs3/projects/(default)/CefDialogHandler.html
@rogerwang is this something you can fix? I would really prefer not having to fall-back on zennity for my Linux builds. In Windows, the "New Folder" button is present, so this only impacts Linux (and possibly macOS).
Verified that with <input nwdirectory type="file"> on Ubuntu 20 with NW.js 0.59.0 that the dialogue offers no way to create a folder. "zennity" is not built in to Ubuntu 20, so I was not able to test that approach.
Tested in a fresh install of Ubuntu 21 with NW.js 0.59.0 and the dialog now has a "Create New Folder" button built in by default.

Turns out it's "zenity" not "zennity", sorry! It does appear to be installed by default with Ubuntu 20.04.
Very strange that this is somehow fixed with Ubuntu 21. Since Zenity and others are showing the create button in 20.04, I'm guessing whatever library is used to draw that window changed a default value between Ubuntu 20 and Ubuntu 21. Theoretically, NW.js could set that value instead of relying on a valid default (thus requiring users to upgrade their OS to get a fix).
That said, I'm not seeing anything obvious in the link @frank-dspeed provided. These appear to be the only options for CefDialogHandler:
///// Requires that the file exists before allowing the user to pick it.
/// FILE_DIALOG_OPEN = 0,
///// Like Open, but allows picking multiple files to open.
/// FILE_DIALOG_OPEN_MULTIPLE,
///// Like Open, but selects a folder to open.
/// FILE_DIALOG_OPEN_FOLDER,
///// Allows picking a nonexistent file, and prompts to overwrite if the file// already exists.
/// FILE_DIALOG_SAVE,
///// General mask defining the bits used for the type values.
/// FILE_DIALOG_TYPE_MASK = 0xFF,
///// Prompt to overwrite if the user selects an existing file with the Save// dialog.
/// FILE_DIALOG_OVERWRITEPROMPT_FLAG = 0x01000000,
///// Do not display read- only files.
/// FILE_DIALOG_HIDEREADONLY_FLAG = 0x02000000, } cef_file_dialog_mode_t;
So, I'm guessing the fix would need to be somewhere in libcef: https://github.com/Mojang/cef/blob/master/libcef/browser/file_dialog_manager.cc
All-in-all, likely not worth the effort. However, since 20.04 is still LTS, it would still be appreciated if it's possible to fix this in NW.js.
Thanks @TheJaredWilcurt for digging into it!
@rogerwang I need to ping you again on this. Please let me know if it's something you can add.
There are 2 possible solutions
- is to fix that or lets say add that feature inside CEF or
- is to add a cross platform lib that allows creating dialog boxes https://github.com/mlabbe/nativefiledialog