@@ -21,6 +21,8 @@ import { isLinux, isMacintosh } from 'vs/base/common/platform';
2121import { Codicon , registerIcon , stripCodicons } from 'vs/base/common/codicons' ;
2222import { BaseActionViewItem , ActionViewItem , IActionViewItemOptions } from 'vs/base/browser/ui/actionbar/actionViewItems' ;
2323import { formatRule } from 'vs/base/browser/ui/codicons/codiconStyles' ;
24+ import { isFirefox } from 'vs/base/browser/browser' ;
25+ import { StandardMouseEvent } from 'vs/base/browser/mouseEvent' ;
2426
2527export const MENU_MNEMONIC_REGEX = / \( & ( [ ^ \s & ] ) \) | ( ^ | [ ^ & ] ) & ( [ ^ \s & ] ) / ;
2628export const MENU_ESCAPED_MNEMONIC_REGEX = / ( & a m p ; ) ? ( & a m p ; ) ( [ ^ \s & ] ) / g;
@@ -424,9 +426,29 @@ class BaseMenuActionViewItem extends BaseActionViewItem {
424426 // add back if issues arise and link new issue
425427 EventHelper . stop ( e , true ) ;
426428
427- // Set timout to allow context menu cancellation to trigger
428- // otherwise the action will destroy the menu and context menu
429- // will still trigger
429+ // See https://developer.mozilla.org/en-US/Add-ons/WebExtensions/Interact_with_the_clipboard
430+ // > Writing to the clipboard
431+ // > You can use the "cut" and "copy" commands without any special
432+ // permission if you are using them in a short-lived event handler
433+ // for a user action (for example, a click handler).
434+
435+ // => to get the Copy and Paste context menu actions working on Firefox,
436+ // there should be no timeout here
437+ if ( isFirefox ) {
438+ const mouseEvent = new StandardMouseEvent ( e ) ;
439+
440+ // Allowing right click to trigger the event causes the issue described below,
441+ // but since the solution below does not work in FF, we must disable right click
442+ if ( mouseEvent . rightButton ) {
443+ return ;
444+ }
445+
446+ this . onClick ( e ) ;
447+ }
448+
449+ // In all other cases, set timout to allow context menu cancellation to trigger
450+ // otherwise the action will destroy the menu and a second context menu
451+ // will still trigger for right click.
430452 setTimeout ( ( ) => {
431453 this . onClick ( e ) ;
432454 } , 0 ) ;
0 commit comments