-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Description
I have wrapped the title of a Tab in order to give it a ContextMenu capability on right-click. When a MenuItem in that ContextMenu is clicked, the click appears to propagate to the Tab itself, causing its activation (parent Tabs onChange handler is invoked).
This makes it impossible to handle MenuItem clicks of an inactive Tab, without activating it.
What I've tried
Manually stopping the propagation of the click event in the MenuItem onClick handler stops propagation too early -- the ContextMenu does not close in that case.
Manually activating a different Tab in the MenuItem onClick handler is also too early, the Tab receives the propagated click after the MenuItem onClick handler finishes.
Motivation & Background: When you right-click an inactive Chrome tab and click Duplicate, it opens a new tab right of the original tab and activates the new tab. I am unable to clone this (desirable) behavior with Blueprint due to the propagation issue.
Workaround:
mouseEvent.customFlag = true
in the MenuItem onClick handler- Then check for this flag in the Tabs onChange handler in order to skip the tab change
Environment
- @blueprintjs/core: 6.1.0
- Windows 11 24H2
- Chrome 138
Code Sandbox & Reproduction
- Visit https://codesandbox.io/p/sandbox/5fc46c
- Right-click the 2nd (inactive) tab
- Click the menu item
- Observe the active tab change
- Repeat with propagation checkbox unticked and observe the defunct ContextMenu