feat(Combobox): add unmountOnHide prop - #2842
Conversation
📝 WalkthroughWalkthroughCombobox adds the ChangesCombobox unmount-on-hide
Estimated code review effort: 3 (Moderate) | ~20 minutes Possibly related PRs
Sequence Diagram(s)sequenceDiagram
participant ComboboxRoot
participant ComboboxContent
participant Presence
participant ComboboxContentImpl
participant FocusScope
participant DismissableLayer
ComboboxRoot->>ComboboxContent: Provide unmountOnHide
ComboboxContent->>Presence: Derive forceMount
Presence->>ComboboxContentImpl: Pass present and visibility
ComboboxContentImpl->>FocusScope: Pass present state
ComboboxContentImpl->>DismissableLayer: Pass present state
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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 |
commit: |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@packages/core/src/Combobox/ComboboxContentImpl.vue`:
- Around line 101-109: Update the `watch` callback for `props.present` to detect
any active descendant within `currentElement`, rather than relying only on
`isInputWithinContent.value`. When content hides and the active element is
inside the content—including slotted `option-state` inputs—restore focus to
`rootContext.triggerElement` after `nextTick`, while preserving the existing
guards for unrelated active elements.
- Around line 57-58: Update the scroll-lock watcher beside useBodyScrollLock to
react to both props.present and props.bodyLock, ensuring scrollLocked is
recomputed and released when bodyLock becomes false while content remains
present. Add a regression test covering a bodyLock change from true to false
while the combobox is open.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: 3018224d-d636-4948-a32c-4716ce88fea1
📒 Files selected for processing (8)
docs/content/meta/ComboboxRoot.mdpackages/core/src/Autocomplete/AutocompleteRoot.vuepackages/core/src/Combobox/Combobox.test.tspackages/core/src/Combobox/ComboboxContent.vuepackages/core/src/Combobox/ComboboxContentImpl.vuepackages/core/src/Combobox/ComboboxRoot.vuepackages/core/src/Combobox/story/_ComboboxManualFilter.vuepackages/core/src/Combobox/story/_ComboboxObject.vue
🔗 Linked issue
Follows the Dialog precedent in #2662.
❓ Type of change
📚 Description
Adds
unmountOnHidetoComboboxRoot, defaulting totrue. Whenfalse, content stays mounted but hidden while closed, preserving expensive option subtrees and internal state across open cycles.Closed persistent content is excluded from focus, dismissal, body-scroll-lock, and surrounding-content ARIA behavior.
ComboboxContent.forceMountkeeps its existing low-level semantics. Tests cover persistence, unchanged defaults, event safety, body-lock changes, multiple instances, and cleanup.📸 Screenshots (if appropriate)
Not applicable.
📝 Checklist
Summary by CodeRabbit
New Features
unmountOnHideoption to Combobox, defaulting totrue.unmountOnHidetofalse.Bug Fixes