Skip to content

Commit 155261e

Browse files
authored
Merge pull request #66 from github/colinwm-combobox-commit
Send original event details in combobox-commit CustomEvent
2 parents 2186abb + 9daad1b commit 155261e

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/index.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ function commitWithElement(event: MouseEvent) {
173173
const target = event.target.closest('[role="option"]')
174174
if (!target) return
175175
if (target.getAttribute('aria-disabled') === 'true') return
176-
fireCommitEvent(target)
176+
fireCommitEvent(target, {event})
177177
}
178178

179179
function commit(input: HTMLTextAreaElement | HTMLInputElement, list: HTMLElement): boolean {
@@ -184,8 +184,8 @@ function commit(input: HTMLTextAreaElement | HTMLInputElement, list: HTMLElement
184184
return true
185185
}
186186

187-
function fireCommitEvent(target: Element): void {
188-
target.dispatchEvent(new CustomEvent('combobox-commit', {bubbles: true}))
187+
function fireCommitEvent(target: Element, detail?: Record<string, unknown>): void {
188+
target.dispatchEvent(new CustomEvent('combobox-commit', {bubbles: true, detail}))
189189
}
190190

191191
function visible(el: HTMLElement): boolean {

0 commit comments

Comments
 (0)