mirror of
https://github.com/jcreek/SvelteKitSaasBoilerplate.git
synced 2026-07-13 02:53:50 +00:00
refactor(#35): add guard clause to escape event listener if dropdown is not open
This commit is contained in:
@@ -13,10 +13,8 @@
|
||||
|
||||
onMount(() => {
|
||||
const handleClick = (event: MouseEvent) => {
|
||||
if (!dropdown.contains(event.target as Node) && isOpen) {
|
||||
isOpen = false;
|
||||
}
|
||||
if (event.target instanceof HTMLAnchorElement) {
|
||||
if (!isOpen) return;
|
||||
if (!dropdown.contains(event.target as Node) || event.target instanceof HTMLAnchorElement) {
|
||||
isOpen = false;
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user