Skip to content
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

Merged
merged 3 commits into from
Oct 13, 2021
Merged

Conversation

suzubara
Copy link
Contributor

@suzubara suzubara commented Oct 12, 2021

Summary

This enhances the existing ComboBox component by allowing a user to pass in a custom onChange handler to the underlying text input element (using inputProps). 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:

  • the ID attributes assigned to the list element & assistive hint
  • handling the disabled prop on the correct elements
  • the aria-setsize value on list items

I 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)

combobox

@@ -411,13 +416,13 @@ export const ComboBox = forwardRef(
</button>
</span>
<ul
{...ulProps}
Copy link
Contributor Author

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

brandonlenz
brandonlenz previously approved these changes Oct 13, 2021
Copy link
Contributor

@brandonlenz brandonlenz left a 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'
Copy link
Contributor

@brandonlenz brandonlenz Oct 13, 2021

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?

Copy link
Contributor Author

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.

@suzubara suzubara merged commit 47be106 into main Oct 13, 2021
@suzubara suzubara deleted the sr-combobox-add-new branch October 13, 2021 22:26
@suzubara suzubara mentioned this pull request Oct 19, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: feature New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants