fix(Tabs): only force-mount TabsContent during SSR#2477
fix(Tabs): only force-mount TabsContent during SSR#2477
Conversation
Fixes unovue#2476 The Presence component inside TabsContent has force-mount hardcoded, keeping all inactive tab panels in the DOM. This causes inactive tabs to be visible when any CSS display property (e.g. display:flex) is set on TabsContent, as it overrides the hidden attribute's display:none. This change conditionally applies force-mount only during SSR (when document is undefined) or when the user explicitly passes the forceMount prop, using the existing isBrowser utility.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review infoConfiguration used: defaults Review profile: CHILL Plan: Pro 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughThe TabsContent component now conditionally sets the Changes
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~5 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Tip Try Coding Plans. Let us write the prompt for your AI agent so you can ship faster (with fewer bugs). Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
Note: This is a code-fix only; I have not updated documentation though in retrospect, 9526356 probably should have documented that SSR forces I can update the docs in my PR if you want or I can leave the wording of that up to the maintainers. Happy to take your guidance. |
commit: |
|
Nice fix @dfidler ! A quick comment:
|
Indeed. But that's the documented behaviour. It's the whole point of running tab content through Presence and it's why forceMount exists. Though now that I think on it should presence ever unmount something in the SSR world? Was 9526356 a red herring and forceMount should just be overridden in the SSR world entirely? I honestly don't know as I don't live in that world. But then that turns a really small change into a huge change/risk. |
Fixes #2476
The Presence component inside TabsContent has force-mount hardcoded, keeping all inactive tab panels in the DOM. You can see this either by inspecting the DOM or when CSS display property (e.g. display:flex) is set on TabsContent, as it overrides the hidden attribute's display:none.
This change conditionally applies force-mount only during SSR (when document is undefined) or when the user explicitly passes the forceMount prop, using the existing isBrowser utility.
🔗 Linked issue
#2476
❓ Type of change
📚 Description
Detects if running in SSR/SPA; respects the desire to hydrate all TabsContent in SSR but also respects documented behaviour for SPA
📝 Checklist
Summary by CodeRabbit