-
-
Notifications
You must be signed in to change notification settings - Fork 174
fix: BOffcanvas responsive SSR compatibility - defer breakpoint evaluation to client-side #2833
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
Conversation
|
|
…ation to client-side Co-authored-by: VividLemon <[email protected]>
VividLemon
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested locally, no hydration issue with either in responsive or outside responsive breakpoint
|
Important Review skippedBot user detected. To trigger a single review, invoke the You can disable this status message by setting the Comment |
commit: |
commit: |
* upstream/main: (32 commits) chore: release main (bootstrap-vue-next#2838) feat(BButtonToolbar): Add keyboard navigation support (bootstrap-vue-next#2837) fix(BFormSelect): modelValue not being applied during SSR (bootstrap-vue-next#2835) feat(BTable): Implement keyboard navigation (bootstrap-vue-next#2834) fix: BOffcanvas responsive SSR compatibility - defer breakpoint evaluation to client-side (bootstrap-vue-next#2833) chore: release main (bootstrap-vue-next#2831) fix(BDropdown): transition broken by inline display styles (bootstrap-vue-next#2832) feat: change useColorMode selector from 'body' to 'html' (bootstrap-vue-next#2830) chore: release main (bootstrap-vue-next#2817) feat: Add headerAttrs prop to BOffcanvas and BModal components docs: Add useScrollspy documentation fix: Remove lazy-modifier warning on FormInput docs (bootstrap-vue-next#2825) feat(BSort)!: Implement initial-sort-direction and move compare from sort-by to fields (bootstrap-vue-next#2777) docs(table): fix incorrect list item (bootstrap-vue-next#2823) docs: Fix grammar in documentation data files (bootstrap-vue-next#2816) doc(BTooltip): Parity pass (bootstrap-vue-next#2762) docs(BOverlay): Parity pass (bootstrap-vue-next#2767) feat: implement BFormRating disabled state (bootstrap-vue-next#2753) (bootstrap-vue-next#2793) docs: fix otp for index and reference pages (bootstrap-vue-next#2819) docs(BApp): add some additional details around legacy plugin use (bootstrap-vue-next#2820) ...
The BOffcanvas component with the
responsiveprop was causing hydration mismatch errors in SSR environments due to inconsistent initial state between server and client rendering.Problem
When using BOffcanvas with the
responsiveprop in SSR applications (Nuxt, Next.js, etc.), the component would evaluate breakpoints differently during SSR vs client hydration:useBreakpointsreturns fallback valuesisOpenByBreakpointwould have different initial values, triggering hydration mismatch errorsUsers had to work around this by wrapping the component in client-only components, which defeats the purpose of SSR.
Solution
The fix ensures SSR compatibility by initializing
isOpenByBreakpointwith an SSR-safe default value (false) and deferring the actual breakpoint evaluation to theonMountedhook (client-side only):Benefits
The component now works seamlessly in SSR environments while preserving all responsive functionality after the initial client-side mount.
Fixes #1982.
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.