Fire event on Popover close #1217
Replies: 3 comments
-
For vue part it can be solved with little changes (like currently implemented in Dialog) packages/@headlessui-vue/src/components/popover/popover.ts export let Popover = defineComponent({
...
emits: { close: (_close: boolean) => true },
...
setup(props, { emit, attrs, slots }) {
...
let api = {
...
close(focusableElement: HTMLElement | Ref<HTMLElement | null>) {
...
emit('close', false)
}
...
}
...
}
}) |
Beta Was this translation helpful? Give feedback.
-
Hi for react you can use that:
|
Beta Was this translation helpful? Give feedback.
-
For what it's worth if anyone else is struggling with the same thing, I was able to use a |
Beta Was this translation helpful? Give feedback.
-
In some cases it is useful to know, if popover was closed or not. For example, to reset logic inside PopoverPanel (tabs navigation, etc.). Like
close
event in Dialog.Beta Was this translation helpful? Give feedback.
All reactions