fix(custom-selection): respect disableContextMenu so right-click isn't dead (SD-2944)#3171
Merged
caio-pizzol merged 1 commit intomainfrom May 5, 2026
Merged
Conversation
…t dead (SD-2944) The contextmenu DOM handler in the custom-selection PM extension calls event.preventDefault() unconditionally to keep focus and selection visible while SuperDoc's built-in right-click menu opens. When the consumer sets disableContextMenu: true the built-in UI refuses to open, but the preventDefault still fires, so the browser's native right-click menu and any consumer-attached contextmenu listener are both suppressed. Right-click on plain text inside the editor goes dead with no menu of any kind. Short-circuits the contextmenu handler with a return false (no preventDefault, no focus-preservation transaction) when editor.options.disableContextMenu is true. Default behavior unchanged for consumers using SuperDoc's built-in menu. The mousedown-side selection preservation still runs, so a consumer rendering their own menu sees the visible selection underneath.
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
Contributor
|
🎉 This PR is included in @superdoc-dev/mcp v0.3.0-next.58 The release is available on GitHub release |
Contributor
|
🎉 This PR is included in vscode-ext v2.3.0-next.102 |
Contributor
|
🎉 This PR is included in @superdoc-dev/react v1.2.0-next.100 The release is available on GitHub release |
Contributor
|
🎉 This PR is included in superdoc v1.30.0-next.58 The release is available on GitHub release |
Contributor
|
🎉 This PR is included in superdoc-cli v0.8.0-next.75 The release is available on GitHub release |
Contributor
|
🎉 This PR is included in superdoc-sdk v1.8.0-next.58 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The contextmenu DOM handler in the custom-selection extension preventDefaults every right-click inside the editor so SuperDoc's built-in menu can open over a preserved selection. `disableContextMenu: true` turns the built-in UI off but doesn't reach this handler, so the browser native menu and any consumer-attached `contextmenu` listener are both suppressed. Right-click on plain text inside the editor with the built-in menu disabled is dead today.
Short-circuits the handler when `editor.options.disableContextMenu` is true. Default behavior unchanged. The sibling mousedown-path selection preservation still runs, so a consumer rendering their own `contextmenu` listener sees the visible selection underneath while they decide what to render.
Without this, every consumer using `disableContextMenu` either has to render a menu unconditionally or live with the dead-click. With it, the flag does what it says and leaves SuperDoc out of the right-click flow.
Verified: `pnpm exec vitest run src/editors/v1/extensions/context-menu src/editors/v1/extensions/custom-selection src/editors/v1/components/context-menu` -> 207 passed (8 files, +2 new in custom-selection.test.js).