-
Notifications
You must be signed in to change notification settings - Fork 81
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
feat: Add input onChange handler to ComboBox #1689
Conversation
@@ -411,13 +416,13 @@ export const ComboBox = forwardRef( | |||
</button> | |||
</span> | |||
<ul | |||
{...ulProps} |
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 also moved the custom props for these elements up, to avoid mistakenly overwriting required props
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.
Very cool! I have one question, not really impacting approval haha
@@ -31,7 +31,7 @@ export { Grid } from './components/grid/Grid/Grid' | |||
/** Form components */ | |||
export { CharacterCount } from './components/forms/CharacterCount/CharacterCount' | |||
export { Checkbox } from './components/forms/Checkbox/Checkbox' | |||
export { ComboBox } from './components/forms/ComboBox/ComboBox' | |||
export { ComboBox, ComboBoxOption } from './components/forms/ComboBox/ComboBox' |
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.
My understanding here is that ComboBoxOption used mostly for internal type safety, but now with the onChange handler, we expose it in case someone wants to use that componentinterface with their handler?
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.
this was actually unrelated to the onChange
addition! because the options
passed into a ComboBox component have to match this type, I found it helpful to export this type as well to reference in the consumer app.
Summary
This enhances the existing ComboBox component by allowing a user to pass in a custom
onChange
handler to the underlying text input element (usinginputProps
). This capability is required by the USSF Portal project, where we want to allow users to add a custom option to the dropdown. I've added a Storybook example to illustrate this use case.I also made some small adjustments to the ComboBox markup, to match the USWDS implementation. This came up while testing, because I found out the ComboBox
id
attribute was on the wrong element. Changes include:disabled
prop on the correct elementsaria-setsize
value on list itemsI found a few other discrepancies and noted them in #1690
Related Issues or PRs
There is no existing issue for this ask.
How To Test
View the ComboBox Custom Input Change Handler story in Storybook. Verify existing ComboBox functionality did not break.
Screenshots (optional)