Skip to content

Comments

feat(vue/popover): add restoreFocus opt-out for popover input trigger refocus#3850

Open
ignatremizov wants to merge 1 commit intotailwindlabs:mainfrom
ignatremizov:fix/vue-popover-restore-focus-optout
Open

feat(vue/popover): add restoreFocus opt-out for popover input trigger refocus#3850
ignatremizov wants to merge 1 commit intotailwindlabs:mainfrom
ignatremizov:fix/vue-popover-restore-focus-optout

Conversation

@ignatremizov
Copy link

@ignatremizov ignatremizov commented Feb 21, 2026

Summary

  • add a restoreFocus prop to Vue Popover (default true for backwards-compat) to let consumers opt out of trigger refocus on close
  • thread the option through outside-click and close() restoration paths
  • keep existing behavior unchanged by default

Why

Vue Popover currently always restores focus to the trigger on close. Some input-driven popover UIs need to close without refocusing the input trigger.

Closes #3849

Tests

  • add coverage for restoreFocus=false when closing via close()
  • add coverage for outside-click close when restoreFocus=false
  • add coverage for input trigger + outside-click with restoreFocus=false

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)
@vercel
Copy link

vercel bot commented Feb 21, 2026

@ignatremizov is attempting to deploy a commit to the Tailwind Labs Team on Vercel.

A member of the Team first needs to authorize it.

@ignatremizov ignatremizov changed the title feat(vue/popover): add restoreFocus opt-out for trigger refocus feat(vue/popover): add restoreFocus opt-out for popover input trigger refocus Feb 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Popover (Vue): support disabling trigger focus restoration on close

1 participant