Skip to content

Fix Menu's Appearing Behind Home Content#394

Merged
PauloMFJ merged 7 commits into
datacommonsorg:mainfrom
madebypxlp:paulo/fix-menu-appearing-behind
Jul 14, 2026
Merged

Fix Menu's Appearing Behind Home Content#394
PauloMFJ merged 7 commits into
datacommonsorg:mainfrom
madebypxlp:paulo/fix-menu-appearing-behind

Conversation

@PauloMFJ

@PauloMFJ PauloMFJ commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

Overview

Implemented Portal element to fix open Menu showing behind home content.

Fixed focus events in InFrontOfCanvas getting consumed by tldraw. To do so implemented new capture config option on useKeyDown.

Re-ordered zoom options:
image

Tickets:
image
image

@PauloMFJ PauloMFJ self-assigned this Jul 6, 2026

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a new Portal primitive to lift canvas elements above tldraw's stacking context, refactors the Menu component, and updates the useFocusTrap and useKeydown hooks to improve keyboard navigation. Key feedback includes: avoiding a global capture-phase listener in useKeydown to prevent breaking event propagation, optimizing the Portal component to prevent DOM recreation and state loss on className changes, retaining the focus trap in the Menu component for accessibility, and refining the tabbable elements selector in useFocusTrap to support all non-negative tab indices.

Comment thread dataweaver/apps/web/src/hooks/use_keydown.ts Outdated
Comment thread dataweaver/apps/web/src/components/primitives/portal.tsx
Comment thread dataweaver/apps/web/src/components/elements/menu.tsx
Comment thread dataweaver/apps/web/src/components/elements/menu.tsx
Comment thread dataweaver/apps/web/src/hooks/use_focus_trap.ts

@nick-nlb nick-nlb left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you Paulo - a couple of comments before merging, but otherwise looks great.


useEffect(() => {
const element = document.createElement('div');
if (className) element.className = className;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This effect really does two things. Assuming that the className might change independently of the initial mounting, this triggers the mounting (ie.. setMountedElement) when the class changes. We can separate these into two separate effects, a primary mounting effect and a secondary className change effect.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good spot - updated!

return () => removeListener(eventTarget, listener, capture);
}
}, [config.isEnabled, config.target, keyCode, callback]);
}, [config.isEnabled, config.target, config.capture, keyCode, callback]);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the callback is not memoized coming in to this, then we might see a significant amount of churn here. This isn't new to this PR, but something to flag for later.

@PauloMFJ PauloMFJ Jul 14, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good spot. In theory with React Compiler functions are memorised so shouldn't be an issue? previously experienced some weird instances where React Compiler didn't behave as expected and lack of memorised callback caused issues. Added ticket to review later.


useKeydown('Escape', onClose);

// TODO: For now this doesn't seem to really work due to TLDraw consuming

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment also exists in menu_chart_options.tsx and can be removed from there as well.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This fix is unrelated the the Menu Chart Options issue here which I fixed in: #399. Will leave as is as the latter PR removes comment alongside the corresponding fix.

Comment thread dataweaver/apps/web/src/hooks/use_keydown.ts Outdated
@PauloMFJ
PauloMFJ merged commit 43c125c into datacommonsorg:main Jul 14, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants