From f031f1180471b87a64d6f4fdc1e31c8e3c4d0399 Mon Sep 17 00:00:00 2001 From: Freya Gustavsson Date: Tue, 24 Feb 2026 17:44:42 +0100 Subject: [PATCH] lib: Use browser context menu on shift 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: https://github.com/cockpit-project/cockpit/issues/22919 See-also: https://developer.mozilla.org/en-US/docs/Web/API/Element/contextmenu_event Signed-off-by: Freya Gustavsson --- pkg/lib/cockpit-components-context-menu.tsx | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/pkg/lib/cockpit-components-context-menu.tsx b/pkg/lib/cockpit-components-context-menu.tsx index 6a7fdff537e4..9bdaae8c30d2 100644 --- a/pkg/lib/cockpit-components-context-menu.tsx +++ b/pkg/lib/cockpit-components-context-menu.tsx @@ -26,6 +26,13 @@ export const ContextMenu = ({ parentId, children } : { React.useEffect(() => { const _handleContextMenu = (event: MouseEvent) => { + /* In Firefox they explicitly prevent us from interrupting when holding shift while + * right-clicking for context. Lets make it default for all browsers so they can inspect et. al. + */ + if (event.shiftKey) { + setVisible(false); + return; + } event.preventDefault(); setVisible(true);