Skip to content

lib: Use browser context menu on shift#22920

Merged
mvollmer merged 1 commit intocockpit-project:mainfrom
Venefilyn:lib/prevent-context-on-shift
Feb 26, 2026
Merged

lib: Use browser context menu on shift#22920
mvollmer merged 1 commit intocockpit-project:mainfrom
Venefilyn:lib/prevent-context-on-shift

Conversation

@Venefilyn
Copy link
Member

@Venefilyn Venefilyn commented Feb 24, 2026

With Firefox explicitly preventing pages from interrupting the browser
context menu while holding shift we should adopt that to all browsers.

This is a quality of life thing where users will now be able to access
inspect or any other extension-related context menu items that was
otherwise difficult for them to do.

Fixes: #22919
See-also: https://developer.mozilla.org/en-US/docs/Web/API/Element/contextmenu_event
Signed-off-by: Freya Gustavsson freya@venefilyn.se

Use browser's context menu when holding Shift

To help with accessibility and user-specific items in your browser context menu we now follow the behavior seen in Firefox. Holding Shift key while right-clicking will now skip our own context menu and instead use the default behavior of your browser. Note that while Cockpit Files uses the Cockpit context menu it did not get the update before this release, but is scheduled for next release.

Terminal page showing the shell 'spytec@vm1' with the Firefox context menu popup visible. In it are grayed out items 'Undo, Redo', followed by 'Cut, Copy, Paste', then grayed out 'Delete, Select All', then 'This Frame' with an right-pointing caret on the right of the row.

With Firefox explicitly preventing pages from interrupting the browser
context menu while holding shift we should adopt that to all browsers.

This is a quality of life thing where users will now be able to access
inspect or any other extension-related context menu items that was
otherwise difficult for them to do.

Fixes: cockpit-project#22919
See-also: https://developer.mozilla.org/en-US/docs/Web/API/Element/contextmenu_event
Signed-off-by: Freya Gustavsson <freya@venefilyn.se>
Comment on lines +32 to +34
if (event.shiftKey) {
setVisible(false);
return;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These 3 added lines are not executed by any test. Details

@Venefilyn Venefilyn requested review from jelly and mvollmer February 25, 2026 14:15
Copy link
Member

@mvollmer mvollmer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Good idea!

@mvollmer mvollmer merged commit e04e20b into cockpit-project:main Feb 26, 2026
92 checks passed
@Venefilyn Venefilyn deleted the lib/prevent-context-on-shift branch February 27, 2026 12:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Allow browser contextmenu while holding shift

3 participants