-
Notifications
You must be signed in to change notification settings - Fork 171
[Bug]: TopNavigation size changes after SSR hydration #3337
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
Comments
Hey @TrevorBurnham, thanks for lettings us know. We'll review your request and keep you posted if an update is available. |
Hey @TrevorBurnham |
Would you accept a PR for this? I’m happy to contribute, but I could use more context on why the responsive behavior is currently implemented with JS instead of CSS. |
Hey @TrevorBurnham |
This commit switches from JavaScript-based breakpoints to CSS container queries for TopNavigation, making its appearance consistent when rendered with SSR. To support container queries, we need `container-type: inline-size;` on the TopNavigation root element. This causes overflowing content to get clipped (at least in Safari), so I've enabled `expandToViewport` to render utility dropdowns in a portal. Note that OverflowMenu doesn't need this treatment because it expands the height of TopNavigation rather than overflowing. Fixes cloudscape-design#3337
I've submitted a PR to fix this issue: #3371 |
This commit switches from JavaScript-based breakpoints to CSS container queries for TopNavigation, making its appearance consistent when rendered with SSR. To support container queries, we need `container-type: inline-size;` on the TopNavigation root element. This causes overflowing content to get clipped (at least in Safari), so I've enabled `expandToViewport` to render utility dropdowns in a portal. Note that OverflowMenu doesn't need this treatment because it expands the height of TopNavigation rather than overflowing. Fixes #3337
This commit switches from JavaScript-based breakpoints to CSS container queries for TopNavigation, making its appearance consistent when rendered with SSR. To support container queries, we need `container-type: inline-size;` on the TopNavigation root element. This causes overflowing content to get clipped (at least in Safari), so I've enabled `expandToViewport` to render utility dropdowns in a portal. Note that OverflowMenu doesn't need this treatment because it expands the height of TopNavigation rather than overflowing. Fixes cloudscape-design#3337
This commit switches from JavaScript-based breakpoints to CSS container queries for TopNavigation, making its appearance consistent when rendered with SSR. To support container queries, we need `container-type: inline-size;` on the TopNavigation root element. This causes overflowing content to get clipped (at least in Safari), so I've enabled `expandToViewport` to render utility dropdowns in a portal. Note that OverflowMenu doesn't need this treatment because it expands the height of TopNavigation rather than overflowing. Fixes cloudscape-design#3337
This commit switches from JavaScript-based breakpoints to CSS container queries for TopNavigation, making its appearance consistent when rendered with SSR. To support container queries, we need `container-type: inline-size;` on the TopNavigation root element. This causes overflowing content to get clipped (at least in Safari), so I've enabled `expandToViewport` to render utility dropdowns in a portal. Note that OverflowMenu doesn't need this treatment because it expands the height of TopNavigation rather than overflowing. Fixes #3337
This commit switches from JavaScript-based breakpoints to CSS container queries for TopNavigation, making its appearance consistent when rendered with SSR. To support container queries, we need `container-type: inline-size;` on the TopNavigation root element. This causes overflowing content to get clipped (at least in Safari), so I've enabled `expandToViewport` to render utility dropdowns in a portal. Note that OverflowMenu doesn't need this treatment because it expands the height of TopNavigation rather than overflowing. Fixes cloudscape-design#3337
Browser
No response
Package version
v3.0.913
React version
v18.3.1
Description
On my page that uses SSR, I noticed that the top navigation immediately resized after pageload, going from a "narrow" mode to a larger style:
I also noticed that the class
awsui_narrow_k5dlb_2ayr9_187
was attached to the top navigation in the page source, but removed after the page's JS executed.I believe this code is responsible for the issue.
Deferring the breakpoint logic until the code runs on the client wouldn't solve the issue, since there could still be a mismatch between the appearance of the component as rendered in SSR and its appearance on the client. I believe the best solution would be to use CSS media queries instead of JavaScript to implement the breakpoint-based appearance modifiers.
Source code
No response
Reproduction
Render the top navigation with SSR and open in a desktop browser. When I noticed the issue, my browser viewport was 1024x wide.
Code of Conduct
The text was updated successfully, but these errors were encountered: