-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
replace manage facility admin screen dropdowns with combos (#6439)
* refactor using truss * add tests * temporarily wrap things in act * fix accessibility violations and refactor tests * scope down unnecessary changes * use recommended userEvent setup pattern * fix mocks * move gql alias to before each hook * switch selector * rework e2e to work with combo box * add org util query to simplify selectors * add extracted combo box component * add forwardRef hook * relax label selectors
- Loading branch information
Showing
7 changed files
with
319 additions
and
181 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import { ComboBox as TrussComboBox, Label } from "@trussworks/react-uswds"; | ||
import React, { ComponentPropsWithRef, forwardRef } from "react"; | ||
|
||
import Required from "./Required"; | ||
|
||
type TrussComponentProps = ComponentPropsWithRef<typeof TrussComboBox>; | ||
export type ComboBoxProps = TrussComponentProps & { | ||
required?: boolean; | ||
}; | ||
|
||
// props here are only the required ones from Truss and can be extended | ||
// as needed with additional values. | ||
const ComboBox: React.FC<ComboBoxProps> = forwardRef(function ( | ||
{ id, name, required, options, onChange, disabled }: ComboBoxProps, | ||
ref | ||
) { | ||
return ( | ||
<> | ||
<Label htmlFor={id}> | ||
{name} {required && <Required />} | ||
</Label> | ||
<TrussComboBox | ||
name={name} | ||
id={id} | ||
options={options} | ||
onChange={onChange} | ||
disabled={disabled} | ||
ref={ref} | ||
inputProps={{ "aria-required": required }} | ||
/> | ||
</> | ||
); | ||
}); | ||
|
||
export default ComboBox; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.