[navigation menu] Add keepMounted prop to Content part#3794
[navigation menu] Add keepMounted prop to Content part#3794atomiks merged 2 commits intomui:masterfrom
keepMounted prop to Content part#3794Conversation
commit: |
Bundle size report
Check out the code infra dashboard for more information about this PR. |
✅ Deploy Preview for base-ui ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
eb4920e to
f87bf7e
Compare
Greptile OverviewGreptile SummaryAdds
Confidence Score: 4/5
Important Files Changed
|
|
I'd make this opt-in to avoid potential performance hits. With it enabled by default, the initial payload received from the server is larger. The browser also adds these elements to the DOM just to remove them a split-second later. It doesn't have to lay out or paint, so it's not a huge issue, but memory will be allocated, increasing the GC pressure. |
|
@michaldudak yeah good point, I figured navigation menus should always be mounted for SEO, but we can keep it opt-in with Alternatively (and this actually is probably necessary), we could keep the mounted content in the DOM at all times, since Google might re-evaluate contents after hydration finishes. |
a26220e to
2c25435
Compare
keepMounted prop to Content part
| portalContainer, | ||
| ); | ||
|
|
||
| if (keepMounted) { |
There was a problem hiding this comment.
A comment explaining what's going on here could be useful for future readers.
There was a problem hiding this comment.
I removed the clone approach to be simpler
9caaf09 to
9d6a90b
Compare
9d6a90b to
8dfc03e
Compare
8dfc03e to
da85a35
Compare
Closes #3755
<NavigationMenu.Content keepMounted>will keep the content mounted in the DOM with ahiddenattribute during SSR and after hydration - this ensures the content is crawlable. Whenever it should be inserted into the popup, the component moves in there permanently, and stays mounted inside.<NavigationMenu.Portal keepMounted>needs to be used for it to "stay" on the DOM after it gets moved.