This commit is contained in:
Timothy Jaeryang Baek
2026-06-01 13:03:13 -07:00
parent 01810e32ad
commit 346dab3d8f
5 changed files with 30 additions and 15 deletions
+10 -3
View File
@@ -45,10 +45,18 @@
e.preventDefault();
toggleOpen();
}
function handleKeydown(e) {
if (e.key === 'Enter' || e.key === ' ') {
e.preventDefault();
toggleOpen();
}
}
node.addEventListener('click', handleClick);
node.addEventListener('keydown', handleKeydown);
return {
destroy() {
node.removeEventListener('click', handleClick);
node.removeEventListener('keydown', handleKeydown);
}
};
}
@@ -161,9 +169,7 @@
on:resize={positionContent}
/>
<!-- svelte-ignore a11y-click-events-have-key-events -->
<!-- svelte-ignore a11y-no-static-element-interactions -->
<span use:trigger style="display: contents; cursor: pointer;">
<span use:trigger style="display: contents; cursor: pointer;" role="button" aria-haspopup="true" aria-expanded={show}>
<slot />
</span>
@@ -174,6 +180,7 @@
use:portal
bind:this={contentEl}
class={contentClass}
role="menu"
transition:flyAndScale
on:click={(e) => e.stopPropagation()}
on:pointerdown={(e) => e.stopPropagation()}