-
Notifications
You must be signed in to change notification settings - Fork 20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Send original event details in combobox-commit CustomEvent #66
Conversation
👋 Hello and thanks for pinging us! This issue or PR has been added to our inbox and a Design Infrastructure first responder will review it soon.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me!
src/index.ts
Outdated
function fireCommitEvent(target: Element, originalEvent?: MouseEvent): void { | ||
target.dispatchEvent(new CustomEvent('combobox-commit', {bubbles: true, detail: {originalEvent}})) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nitpick; What do you think about taking in details
as a argument so that we adhere more to the API of CustomEvent
?
function fireCommitEvent(target: Element, originalEvent?: MouseEvent): void { | |
target.dispatchEvent(new CustomEvent('combobox-commit', {bubbles: true, detail: {originalEvent}})) | |
function fireCommitEvent(target: Element, detail: Record<string, unknown> | undefined = undefined): void { | |
target.dispatchEvent(new CustomEvent('combobox-commit', {bubbles: true, detail})) |
(☝🏻 I wrote this suggestion in the GitHub comment box so it might be wrong)
src/index.ts
Outdated
@@ -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, originalEvent?: MouseEvent): void { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit. For simplicity and consistency with the other arguments in this file, I think this could just be event
as there's no superseding assignment or event mutation inside the closure. When I see original*, I usually expect something to happen to it after but it's just being forwarded here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
I want to get some additional information about the originating trigger of the commit event (whether the
ctrlKey
ormetaKey
are pressed) to determine whether links should be opened in a new tab or not. Seems that information is not preserved in thecombobox-commit
CustomEvent.I plumbed it through via details, lmk if you think this is reasonable