[x] I have done a quick search on the issue tracker to check if the bug report is not redundant
Context
If there is no context menu defined in a layout file and when I try to open a context menu within the webview corresponding to the layout file, then a black page will render and the webview will crash. I want to prevent this behavior from happening.
If there is a key-value pair for a contextMenu then remove it. An example of what that would look like is below:
"contextMenu": {
"commands": "objectives.json"
}
Save the file
Open the webview that corresponds to the viewpoint without the contextMenu
Verify that after right clicking the webview crashes
Current result
A black screen is rendered and the webview crashes.
Expected result
A black screen is not rendered and the webview does not crash.
Additional context
Developer Console Log:
Uncaught TypeError: Cannot read properties of undefined (reading 'commands')
at availableCommands (index.js:154825:64)
at ContextMenu (index.js:154830:223)
at renderWithHooks (index.js:14091:27)
at mountIndeterminateComponent (index.js:16841:21)
at beginWork (index.js:17822:22)
at HTMLUnknownElement.callCallback2 (index.js:5594:22)
at Object.invokeGuardedCallbackDev (index.js:5619:24)
at invokeGuardedCallback (index.js:5653:39)
at beginWork$1 (index.js:21681:15)
at performUnitOfWork (index.js:21117:21)
index.js:154825 Uncaught TypeError: Cannot read properties of undefined (reading 'commands')
at availableCommands (index.js:154825:64)
at ContextMenu (index.js:154830:223)
at renderWithHooks (index.js:14091:27)
at mountIndeterminateComponent (index.js:16841:21)
at beginWork (index.js:17822:22)
at HTMLUnknownElement.callCallback2 (index.js:5594:22)
at Object.invokeGuardedCallbackDev (index.js:5619:24)
at invokeGuardedCallback (index.js:5653:39)
at beginWork$1 (index.js:21681:15)
at performUnitOfWork (index.js:21117:21)
index.js:15956 The above error occurred in the <ContextMenu> component:
at ContextMenu (https://file+.vscode-resource.vscode-cdn.net/Users/levitt/git/opencaesar/oml-vision/build/static/index.js:154752:3)
at div
at Tree (https://file+.vscode-resource.vscode-cdn.net/Users/levitt/git/opencaesar/oml-vision/build/static/index.js:163352:3)
at div
at TreeView (https://file+.vscode-resource.vscode-cdn.net/Users/levitt/git/opencaesar/oml-vision/build/static/index.js:163760:24)
at QueryClientProvider (https://file+.vscode-resource.vscode-cdn.net/Users/levitt/git/opencaesar/oml-vision/build/static/index.js:123405:3)
at WizardsProvider (https://file+.vscode-resource.vscode-cdn.net/Users/levitt/git/opencaesar/oml-vision/build/static/index.js:123692:36)
at CommandProvider (https://file+.vscode-resource.vscode-cdn.net/Users/levitt/git/opencaesar/oml-vision/build/static/index.js:123652:13)
at RenderedRoute (https://file+.vscode-resource.vscode-cdn.net/Users/levitt/git/opencaesar/oml-vision/build/static/index.js:120242:5)
at Routes (https://file+.vscode-resource.vscode-cdn.net/Users/levitt/git/opencaesar/oml-vision/build/static/index.js:120525:15)
at Router (https://file+.vscode-resource.vscode-cdn.net/Users/levitt/git/opencaesar/oml-vision/build/static/index.js:120472:15)
at MemoryRouter (https://file+.vscode-resource.vscode-cdn.net/Users/levitt/git/opencaesar/oml-vision/build/static/index.js:120434:5)
at App (https://file+.vscode-resource.vscode-cdn.net/Users/levitt/git/opencaesar/oml-vision/build/static/index.js:180016:23)
at LayoutProvider (https://file+.vscode-resource.vscode-cdn.net/Users/levitt/git/opencaesar/oml-vision/build/static/index.js:123619:35)
Consider adding an error boundary to your tree to customize error handling behavior.
Visit https://reactjs.org/link/error-boundaries to learn more about error boundaries.
index.js:154825 Uncaught TypeError: Cannot read properties of undefined (reading 'commands')
at availableCommands (index.js:154825:64)
at ContextMenu (index.js:154830:223)
at renderWithHooks (index.js:14091:27)
at mountIndeterminateComponent (index.js:16841:21)
at beginWork (index.js:17822:22)
at beginWork$1 (index.js:21669:22)
at performUnitOfWork (index.js:21117:21)
at workLoopSync (index.js:21053:13)
at renderRootSync (index.js:21032:15)
at recoverFromConcurrentError (index.js:20652:28)
Possible fix
The bug is in view/src/components/Diagram/Diagram.tsx, view/src/components/Table/Table.tsx, and view/src/components/Tree/Tree.tsx components where the component is being rendered
Need to add a conditional to not render the component if the layout.contextMenu variable is undefined
Technical data
Operating system: Darwin localhost 22.6.0 Darwin Kernel Version 22.6.0: Sun Dec 17 22:12:45 PST 2023; root:xnu-8796.141.3.703.2~2/RELEASE_ARM64_T6000 arm64
Checklist before submitting a bug report
Context
If there is no context menu defined in a layout file and when I try to open a context menu within the webview corresponding to the layout file, then a black page will render and the webview will crash. I want to prevent this behavior from happening.
Steps to reproduce the bug
src/vision/viewpoints
files.contextMenu
then remove it. An example of what that would look like is below:contextMenu
Current result
A black screen is rendered and the webview crashes.
Expected result
A black screen is not rendered and the webview does not crash.
Additional context
Developer Console Log:
Possible fix
The bug is in component is being rendered
view/src/components/Diagram/Diagram.tsx
,view/src/components/Table/Table.tsx
, andview/src/components/Tree/Tree.tsx
components where theNeed to add a conditional to not render the component if the layout.contextMenu variable is
undefined
Technical data
Darwin localhost 22.6.0 Darwin Kernel Version 22.6.0: Sun Dec 17 22:12:45 PST 2023; root:xnu-8796.141.3.703.2~2/RELEASE_ARM64_T6000 arm64
1.88.0