This commit addresses an issue where multiple context menus could be open at the same time.
The fix involves the following:
- Modified `MenuContext` in `app/hooks/useMenuContext.tsx` to store a reference to the `hide` function of the currently open menu, instead of a boolean.
- Updated the `ContextMenu` component in `app/components/ContextMenu/index.tsx` to:
- Use the modified `MenuContext`.
- Before opening a new menu, check if another menu is already open.
- If an existing menu is open, it's closed before the new one is displayed.
Testing:
- I attempted to add a test for this change. However, due to a Node.js version incompatibility (sandbox: 18.19.1 vs. required: >=18.20 for a transitive dependency `lru-cache@^11.0.0` of `jest-environment-jsdom`), I was not able to run Jest tests in the development environment.
- I recommend that you run tests in a compatible Node.js environment, such as in your CI/CD pipeline, to ensure the new behavior is correctly tested and existing functionality remains unaffected.