electron-editor-context-menu icon indicating copy to clipboard operation
electron-editor-context-menu copied to clipboard

Documentation issue

Open po5i opened this issue 7 years ago • 1 comments

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);
});

po5i avatar Oct 16 '17 16:10 po5i

Hm can you determine why? That seems like a bug, which I'd rather not mask with a timeout.

wearhere avatar Oct 16 '17 17:10 wearhere