Skip to content

Commit

Permalink
Merge pull request #66 from github/colinwm-combobox-commit
Browse files Browse the repository at this point in the history
Send original event details in combobox-commit CustomEvent
  • Loading branch information
colinwm authored Dec 14, 2022
2 parents 2186abb + 9daad1b commit 155261e
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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<string, unknown>): void {
target.dispatchEvent(new CustomEvent('combobox-commit', {bubbles: true, detail}))
}

function visible(el: HTMLElement): boolean {
Expand Down

0 comments on commit 155261e

Please sign in to comment.