mirror of
https://github.com/jcreek/SvelteKitSaasBoilerplate.git
synced 2026-07-13 02:53:50 +00:00
refactor(#35): click anywhere handler
This commit is contained in:
@@ -15,9 +15,10 @@
|
||||
};
|
||||
|
||||
onMount(() => {
|
||||
const handleClickAnywhere = (event: MouseEvent) => {
|
||||
if (!isOpen) return;
|
||||
if (!dropdown.contains(event.target as Node) || event.target instanceof HTMLAnchorElement) {
|
||||
const handleClickAnywhere = ({ target }: MouseEvent) => {
|
||||
if (!isOpen || !target) return;
|
||||
const clickTarget = target as HTMLElement;
|
||||
if (!dropdown.contains(clickTarget) || clickTarget.closest('a')) {
|
||||
isOpen = false;
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user