Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Render post menu items lazily (take two) #6473

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open

Conversation

gaearon
Copy link
Contributor

@gaearon gaearon commented Nov 17, 2024

Resubmit of #6437.

I broke dialogs in #6437. We can't put dialogs inside the <Menu.Outer> conditionally rendered content because that would destroy their state and controls, and those need to be alive even after the dialog is closed.

Now I'm unreverting it but applying a few more fixes on top:

  • 6b1640?w=1 applies a slightly different approach. The dialogs are placed outside of <Menu.Outer> so that they don't depend on the menu open/close state. However, the menu itself is not rendered until the first time you press the button. In other words, the menu is now initialized lazily.
  • In ac29593, I move the new component to another file so that we can take advantage of lazy requires where it works.
  • Finally, f03a6c1 tweaks the implementation because useMenuControl only has isOpen for web and I can't figure out how to fix that. This new implementation is ugly but works cross-platform.

Test Plan

Verify the menu works. Verify the dialogs within the menu also work (unlike last time). Verify you can toggle the menu repeatedly. Refresh the page and verify that you can also toggle the menu (both once and repeatedly) using keyboard.

Do this on all platforms.

This is wonky because our useMenuDialog abstraction only has `isOpen` on web. I couldn't figure out a way to make it work xplat so I'm just tracking it myself manually.
Copy link

Old size New size Diff
8.05 MB 8.05 MB 88 B (0.00%)

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