Repository navigation
Conversation
A modal PopoverContent and MenubarContent moved focus back to the trigger even when a closeAutoFocus listener had called preventDefault(). Only run the default focus return when the event has not been prevented, as the non-modal Popover and Dialog already do.
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
commit: |
…-hide Conflicts resolved: - Popper/PopperContent.vue: keep v2's `scope` prop next to the internal `present` prop. - Popover/PopoverContentImpl.vue: keep v2's useContentId/useContentMounted and `scope`. - Popover/PopoverContentModal.vue: keep v2's prevented closeAutoFocus handling (unovue#3283) and hasFocusLeftScope check (unovue#3254) next to the `present` gated scroll lock and hideOthers. - Dialog/Dialog.test.ts, Dialog/DialogContentImpl.vue: take v2. The suppression of closeAutoFocus on the final unmount of kept-mounted content is dropped: a kept-mounted layer must still fire it when it is unmounted (DialogKeptMounted.browser.test.ts). Co-Authored-By: Claude Opus 5.5 <[email protected]>
🔗 Linked issue
Part of #3248
❓ Type of change
📚 Description
With
modalon, callingpreventDefault()in acloseAutoFocushandler does nothing: when the popover closes, focus still jumps back to the trigger. The non-modal Popover and Dialog leave focus alone in that case. This is one of the items in #3248.The modal content handles the event with
.preventand then focuses the trigger without checking whether the listener had already prevented it. I wrapped that inif (!event.defaultPrevented), the same wayDialogContentModaldoes.MenubarContenthad the same problem, and there it even took focus back from wherever the listener had moved it, so I fixed it the same way.Nothing changes if you don't listen to
closeAutoFocus. The existing test only covered the non-modal case, so I extended it to both modes and added Menubar tests; they fail onv2.Here's a playground on 2.11.0: open A, B and C and press Escape. A ends up on body, B and C jump back to their trigger.
📝 Checklist