diff --git a/src/index.ts b/src/index.ts index 220a35f..1f4d5f1 100644 --- a/src/index.ts +++ b/src/index.ts @@ -173,7 +173,7 @@ function commitWithElement(event: MouseEvent) { const target = event.target.closest('[role="option"]') if (!target) return if (target.getAttribute('aria-disabled') === 'true') return - fireCommitEvent(target) + fireCommitEvent(target, {event}) } function commit(input: HTMLTextAreaElement | HTMLInputElement, list: HTMLElement): boolean { @@ -184,8 +184,8 @@ function commit(input: HTMLTextAreaElement | HTMLInputElement, list: HTMLElement return true } -function fireCommitEvent(target: Element): void { - target.dispatchEvent(new CustomEvent('combobox-commit', {bubbles: true})) +function fireCommitEvent(target: Element, detail?: Record): void { + target.dispatchEvent(new CustomEvent('combobox-commit', {bubbles: true, detail})) } function visible(el: HTMLElement): boolean {