feat(vue/popover): add restoreFocus opt-out for popover input trigger refocus#3850
Open
ignatremizov wants to merge 1 commit intotailwindlabs:mainfrom
Open
feat(vue/popover): add restoreFocus opt-out for popover input trigger refocus#3850ignatremizov wants to merge 1 commit intotailwindlabs:mainfrom
ignatremizov wants to merge 1 commit intotailwindlabs:mainfrom
Conversation
Add a new `Popover` prop, `restoreFocus` (default `true`), to control whether close flows automatically move focus back to the trigger. When `restoreFocus` is `false`: - outside click close no longer calls `button.focus()` for non-focusable outside targets - `close()` without an explicit focus target closes the popover without forcing focus restoration - explicit `close(element)` behavior is unchanged and still restores to the provided element Update all internal popover close paths that previously hard-focused the trigger to respect this flag. Tests: - add render-prop close test for `restoreFocus=false` - add outside-click body close test for `restoreFocus=false` - add input-trigger outside-click regression test (`PopoverButton as="input"`) to match datepicker usage Validation: - `npm test -- packages/@headlessui-vue/src/components/popover/popover.test.ts` (80 passed)
|
@ignatremizov is attempting to deploy a commit to the Tailwind Labs Team on Vercel. A member of the Team first needs to authorize it. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
restoreFocusprop to VuePopover(defaulttruefor backwards-compat) to let consumers opt out of trigger refocus on closeclose()restoration pathsWhy
Vue
Popovercurrently always restores focus to the trigger on close. Some input-driven popover UIs need to close without refocusing the input trigger.Closes #3849
Tests
restoreFocus=falsewhen closing viaclose()restoreFocus=falserestoreFocus=false