Skip to content

Commit 3ad86ad

Browse files
committed
ensure we stop the event from propagating
1 parent 452b2c2 commit 3ad86ad

File tree

2 files changed

+6
-0
lines changed
  • packages

2 files changed

+6
-0
lines changed

packages/@headlessui-react/src/components/popover/popover.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -353,6 +353,8 @@ let Button = forwardRefWithAs(function Button<TTag extends ElementType = typeof
353353
if (state.popoverState !== PopoverStates.Open) return closeOthers?.(state.buttonId)
354354
if (!internalButtonRef.current) return
355355
if (!internalButtonRef.current.contains(document.activeElement)) return
356+
event.preventDefault()
357+
event.stopPropagation()
356358
dispatch({ type: ActionTypes.ClosePopover })
357359
break
358360

@@ -603,6 +605,7 @@ let Panel = forwardRefWithAs(function Panel<TTag extends ElementType = typeof DE
603605
if (!internalPanelRef.current) return
604606
if (!internalPanelRef.current.contains(document.activeElement)) return
605607
event.preventDefault()
608+
event.stopPropagation()
606609
dispatch({ type: ActionTypes.ClosePopover })
607610
state.button?.focus()
608611
break

packages/@headlessui-vue/src/components/popover/popover.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -304,6 +304,8 @@ export let PopoverButton = defineComponent({
304304
if (api.popoverState.value !== PopoverStates.Open) return closeOthers?.(api.buttonId)
305305
if (!dom(api.button)) return
306306
if (!dom(api.button)?.contains(document.activeElement)) return
307+
event.preventDefault()
308+
event.stopPropagation()
307309
api.closePopover()
308310
break
309311

@@ -571,6 +573,7 @@ export let PopoverPanel = defineComponent({
571573
if (!dom(api.panel)) return
572574
if (!dom(api.panel)?.contains(document.activeElement)) return
573575
event.preventDefault()
576+
event.stopPropagation()
574577
api.closePopover()
575578
dom(api.button)?.focus()
576579
break

0 commit comments

Comments
 (0)