Quick fix to revert the behaviour of closing the editor window

Can anyone improve on this quick fix?

Problem:
Clicking outside the editor window used to close it, and since recent updates this behaviour was changed. (I believe this change may be reverted in a future update but not sure when.)

Workaround:
Pressing Ctrl-Enter doesn't work when the editor window is not in focus. It's possible to set the scope of the shortcut to work globally (thanks @Steve-Mcl)

BUT...
It has still been annoying me for other reasons - I'll spare you the full tour of my brain's complaint list here though :grinning_face_with_smiling_eyes:

Solution

  • Create a file called "editor-fix.js" in .node-red/public:
(function() {
    RED.events.on("editor:open", function() {
        $("#red-ui-editor-shade").off("mousedown.trayfix");
        $("#red-ui-editor-shade").on("mousedown.trayfix", function(e) {
            if ($(e.target).closest(".red-ui-tray").length === 0) {
                if (!RED.view.dragging && !RED.view.touchDragging) {
                    RED.tray.close();
                }
            }
        });
    });
})();
  • in .node-red/settings.js, add this
    page: {
        scripts: [
            "editor-fix.js"
        ]
    }

to the editorTheme section

THE ISSUE WITH THIS: it doesn't save the editor contents (as per previous behaviour) so if anyone knows how to achieve that with a similar "fix" pls let me know :slight_smile:

Instead of RED.tray.close you could probably call the tray close action RED.actions.invoke('core:confirm-edit-tray')

NOTE: Node-RED v5 (due very soon) has definitely reverted the tray close behaviour. I am not sure if it made it into the 4.1.x stream or not