Repository navigation
fix misleading cut-copy-paste context menu in table and tree view - #134
Merged
Tomasz Naumowicz (tnaum-ms) merged 5 commits intoJun 6, 2025
Conversation
…listener management
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR adds a custom hook to suppress unwanted context menus outside of Monaco editors and integrates it into the DocumentView and CollectionView components.
- Introduced
useSelectiveContextMenuPreventionhook to block context menus on non-editor elements. - Applied the hook in both
DocumentViewandCollectionViewfor consistent behavior.
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| src/webviews/api/webview-client/utils/useSelectiveContextMenuPrevention.ts | New hook that adds/removes a global contextmenu listener with an allowlist of editor selectors. |
| src/webviews/documentdb/documentView/documentView.tsx | Imported and invoked the hook in the DocumentView component. |
| src/webviews/documentdb/collectionView/CollectionView.tsx | Imported and invoked the hook in the CollectionView component. |
Comments suppressed due to low confidence (1)
src/webviews/api/webview-client/utils/useSelectiveContextMenuPrevention.ts:1
- There are no tests covering the new
useSelectiveContextMenuPreventionhook. Adding unit or integration tests to confirm context menus are blocked/allowed as expected would ensure stability.
/*---------------------------------------------------------------------------------------------
…revention.ts Co-authored-by: Copilot <[email protected]>
Tomasz Naumowicz (tnaum-ms)
deleted the
dev/tnaum/81-misleading-cutcopypaste-context-menu-in-tabletree-view
branch
June 6, 2025 05:51
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.
This pull request introduces a new custom hook,
useSelectiveContextMenuPrevention, to improve user experience by selectively disabling context menus in non-editor elements while preserving functionality in Monaco editor components. The hook is integrated into two views (CollectionViewandDocumentView) to enhance their behavior.New feature: Custom hook for context menu prevention
src/webviews/api/webview-client/utils/useSelectiveContextMenuPrevention.ts: Added theuseSelectiveContextMenuPreventionhook, which prevents context menus in non-editor elements while allowing them in Monaco editor elements. This is achieved using an allowlist of selectors and event handling foroncontextmenu.Integration of the custom hook
src/webviews/documentdb/collectionView/CollectionView.tsx: Imported and invokeduseSelectiveContextMenuPreventionwithin theCollectionViewcomponent to manage context menu behavior. [1] [2]src/webviews/documentdb/documentView/documentView.tsx: Imported and invokeduseSelectiveContextMenuPreventionwithin theDocumentViewcomponent to ensure consistent context menu handling. [1] [2]