Skip to content

Commit 2086ab8

Browse files
authored
fix: Correctly pass down classname props to Combobox component (#3143)
1 parent 870165d commit 2086ab8

File tree

2 files changed

+25
-1
lines changed

2 files changed

+25
-1
lines changed

src/components/forms/ComboBox/ComboBox.stories.tsx

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,3 +219,27 @@ export const CustomInputChangeHandler = (): JSX.Element => {
219219
</Form>
220220
)
221221
}
222+
223+
export const WithCustomInputClassNames = (): JSX.Element => {
224+
const fruitList = Object.entries(fruits).map(([value, key]) => ({
225+
value: value,
226+
label: key,
227+
}))
228+
229+
return (
230+
<Form onSubmit={noop}>
231+
<Label htmlFor="fruit-custom-class" requiredMarker aria-required error>
232+
Select a fruit
233+
</Label>
234+
<ComboBox
235+
id="fruit-custom-class"
236+
name="fruit-custom-class"
237+
options={fruitList}
238+
onChange={noop}
239+
inputProps={{
240+
className: 'usa-input--error',
241+
}}
242+
/>
243+
</Form>
244+
)
245+
}

src/components/forms/ComboBox/ComboBox.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ const Input = ({
7777
<input
7878
type="text"
7979
{...inputProps}
80-
className="usa-combo-box__input"
80+
className={classnames('usa-combo-box__input', inputProps.className)}
8181
data-testid="combo-box-input"
8282
autoCapitalize="off"
8383
autoComplete="off"

0 commit comments

Comments
 (0)