electron-editor-context-menu
electron-editor-context-menu copied to clipboard
Documentation issue
I found that moving the menu initialization to the timeout function worked instead of the documented version. Otherwise it does not show any suggestions.
My suggestion to be changed on the docs:
window.addEventListener('contextmenu', function(e) {
// Only show the context menu in text editors.
if (!e.target.closest('textarea, input, [contenteditable="true"]')) return;
// The 'contextmenu' event is emitted after 'selectionchange' has fired but possibly before the
// visible selection has changed. Try to wait to show the menu until after that, otherwise the
// visible selection will update after the menu dismisses and look weird.
setTimeout(function() {
var menu = buildEditorContextMenu();
menu.popup(remote.getCurrentWindow());
}, 30);
});
Hm can you determine why? That seems like a bug, which I'd rather not mask with a timeout.