-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Bug]: Cannot close menu/dropdown by clicking iframe #707
Comments
Maybe this can help someone, until a proper fix is implemented: <template>
<Listbox>
<ListboxOptions ref="optionsRef">...</ListboxOptions>
</Listbox>
</template>
<script lang="ts">
export default defineComponent({
setup() {
const optionsRef = ref<typeof ListboxOptions>();
const closeOnIframeClick = async () => {
const activeElement = document.activeElement as HTMLElement | null;
if (activeElement instanceof HTMLIFrameElement) {
optionsRef.value?.el?.dispatchEvent(
new KeyboardEvent("keydown", {
key: "Escape"
})
);
await nextTick();
const ownerActiveElement = activeElement.ownerDocument.activeElement as HTMLElement | null;
if (ownerActiveElement) {
ownerActiveElement.blur?.();
}
}
};
onMounted(() => {
window.addEventListener("blur", closeOnIframeClick);
});
onUnmounted(() => {
window.removeEventListener("blur", closeOnIframeClick);
});
return {
optionsRef
};
}
});
</script> |
Hey! Thank you for your bug report! This should be fixed by #1552, and will be available in the next release. You can already try it using |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
What package within Headless UI are you using?
@headlessui/vue
What version of that package are you using?
v1.4.0
What browser are you using?
Chrome v92
Reproduction repository
https://headlessui.dev/vue/menu
Describe your issue
When a menu/dropdown is open, it cannot be closed by interacting(click) with iframe on the page.
Reproduction:
Expecting: close/blur menu
Result: menu stay as open/focus
Reference: https://gist.github.com/jaydson/1780598
The text was updated successfully, but these errors were encountered: