From eeac1cfa2110221b7e2e30e5a0cf473733ff2d48 Mon Sep 17 00:00:00 2001 From: Baris Palaska Date: Tue, 21 Jul 2026 18:14:06 +0000 Subject: [PATCH] Revert "gpui_web: Only cancel the native context menu when the app claims the right-click" (#61403) Reverts zed-industries/zed#60892 Realised this is probably not the desired behavior. Context menu is not really useful when the app is full canvas. I think it's better to not have the browser context menu on web at all. My bad and sorry for the hassle! --- crates/gpui_web/src/events.rs | 15 ++------------- crates/gpui_web/src/window.rs | 2 -- 2 files changed, 2 insertions(+), 15 deletions(-) diff --git a/crates/gpui_web/src/events.rs b/crates/gpui_web/src/events.rs index 31a37d527f..08434aada4 100644 --- a/crates/gpui_web/src/events.rs +++ b/crates/gpui_web/src/events.rs @@ -151,21 +151,13 @@ impl WebWindowInner { current_state.modifiers = modifiers; } - let result = this.dispatch_input(PlatformInput::MouseDown(MouseDownEvent { + this.dispatch_input(PlatformInput::MouseDown(MouseDownEvent { button, position, modifiers, click_count, first_mouse: false, })); - - // The browser fires `contextmenu` after this event; remember whether - // the app claimed the right-click (e.g. opened its own menu) so the - // contextmenu listener cancels the native menu only in that case. - if button == MouseButton::Right { - let claimed = result.is_some_and(|result| !result.propagate); - this.app_claimed_right_click.set(claimed); - } }) } @@ -279,12 +271,9 @@ impl WebWindowInner { } fn register_context_menu(self: &Rc) -> Closure { - let this = Rc::clone(self); self.listen("contextmenu", move |event: JsValue| { let event: web_sys::Event = event.unchecked_into(); - if this.app_claimed_right_click.replace(false) { - event.prevent_default(); - } + event.prevent_default(); }) } diff --git a/crates/gpui_web/src/window.rs b/crates/gpui_web/src/window.rs index 5f4223572b..b9399d32e6 100644 --- a/crates/gpui_web/src/window.rs +++ b/crates/gpui_web/src/window.rs @@ -55,7 +55,6 @@ pub(crate) struct WebWindowInner { pub(crate) last_physical_size: Cell<(u32, u32)>, pub(crate) notify_scale: Cell, pub(crate) is_composing: Cell, - pub(crate) app_claimed_right_click: Cell, mql_handle: RefCell>, pending_physical_size: Cell>, } @@ -183,7 +182,6 @@ impl WebWindow { last_physical_size: Cell::new((0, 0)), notify_scale: Cell::new(false), is_composing: Cell::new(false), - app_claimed_right_click: Cell::new(false), mql_handle: RefCell::new(None), pending_physical_size: Cell::new(None), });