-
Notifications
You must be signed in to change notification settings - Fork 54
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
replace manage facility admin screen dropdowns with combos #6439
Changes from 10 commits
8c8fdb1
c972ca6
a285c5c
3497425
d9b61f0
20c9677
c424b12
b449eef
397f579
641eb26
831d535
9130d59
54ed7ed
4a21a24
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,25 @@ | ||
import { faSlidersH } from "@fortawesome/free-solid-svg-icons"; | ||
import React from "react"; | ||
import React, { Ref } from "react"; | ||
import { ComboBox, ComboBoxRef, Label } from "@trussworks/react-uswds"; | ||
|
||
import Dropdown, { Option } from "../../commonComponents/Dropdown"; | ||
import Button from "../../commonComponents/Button/Button"; | ||
import SupportHomeLink from "../SupportHomeLink"; | ||
import { Option } from "../../commonComponents/Dropdown"; | ||
import Required from "../../commonComponents/Required"; | ||
|
||
import { ManageFacilityState } from "./ManageFacility"; | ||
|
||
export interface FacilitySelectFilterProps { | ||
organizationOptions: Option[]; | ||
facilityOptions: Option[]; | ||
manageFacilityState: ManageFacilityState; | ||
onClearFilter: () => void; | ||
onSelectOrg: (e: any) => void; | ||
onSelectFacility: (e: any) => void; | ||
onSelectOrg: (selectedOrg: string | undefined) => void; | ||
onSelectFacility: (selectedFacility: string | undefined) => void; | ||
onSearch: (e: any) => void; | ||
manageFacilityState: ManageFacilityState; | ||
loading: boolean; | ||
facilityRef: Ref<ComboBoxRef> | undefined; | ||
orgRef: Ref<ComboBoxRef> | undefined; | ||
} | ||
|
||
const FacilitySelectFilter: React.FC<FacilitySelectFilterProps> = ({ | ||
|
@@ -27,6 +31,8 @@ const FacilitySelectFilter: React.FC<FacilitySelectFilterProps> = ({ | |
onSelectFacility, | ||
onSearch, | ||
loading, | ||
facilityRef, | ||
orgRef, | ||
}) => { | ||
/** | ||
* HTML | ||
|
@@ -43,7 +49,7 @@ const FacilitySelectFilter: React.FC<FacilitySelectFilterProps> = ({ | |
<div className="desktop:grid-col-auto tablet:grid-col-auto mobile:grid-col-12 margin-top-2 tablet:margin-top-0"> | ||
<Button | ||
icon={faSlidersH} | ||
disabled={manageFacilityState.orgId === ""} | ||
disabled={manageFacilityState.orgId === undefined} | ||
onClick={onClearFilter} | ||
ariaLabel="Clear facility selection filters" | ||
> | ||
|
@@ -58,40 +64,47 @@ const FacilitySelectFilter: React.FC<FacilitySelectFilterProps> = ({ | |
className="bg-base-lightest padding-left-3 padding-right-3 padding-bottom-1" | ||
> | ||
<div className="grid-row grid-gap padding-bottom-2 flex-align-end"> | ||
<div className="desktop:grid-col-4 tablet:grid-col-4 mobile:grid-col-1"> | ||
<Dropdown | ||
label="Organization" | ||
options={[ | ||
{ | ||
label: "- Select -", | ||
value: "", | ||
}, | ||
...organizationOptions, | ||
]} | ||
onChange={onSelectOrg} | ||
selectedValue={manageFacilityState.orgId} | ||
<div | ||
data-testid={"org-selection-container"} | ||
className="desktop:grid-col-4 tablet:grid-col-4 mobile:grid-col-1 margin-top-1em" | ||
> | ||
<Label htmlFor="manage-facility-org-select"> | ||
Organization <Required /> | ||
</Label> | ||
<ComboBox | ||
name={"Organization"} | ||
id={"manage-facility-org-select"} | ||
options={organizationOptions} | ||
onChange={(val) => { | ||
onSelectOrg(val); | ||
}} | ||
disabled={loading} | ||
required={true} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The required true was needed to pass a11y scan. Does the combobox handle the required in a different way? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Truss doesn't give us a Worth calling out that we might want to add new component we can extend with things like the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This happens when you test this as a form. I ran through it and it looks like it's still being flagged. I think for the purpose of accessibility we might need to figure out how to add required. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. oh actually Truss gives us an escape hatch for this. Will push a fix soon There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Tested it with axe and didn't find any problems! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
ref={orgRef} | ||
/> | ||
</div> | ||
<div className="desktop:grid-col-4 tablet:grid-col-4 mobile:grid-col-1"> | ||
<Dropdown | ||
label="Testing facility" | ||
options={[ | ||
{ | ||
label: "- Select -", | ||
value: "", | ||
}, | ||
...facilityOptions, | ||
]} | ||
onChange={onSelectFacility} | ||
selectedValue={manageFacilityState.facilityId} | ||
<div | ||
data-testid={"facility-selection-container"} | ||
className="desktop:grid-col-4 tablet:grid-col-4 mobile:grid-col-1 margin-top-1em" | ||
> | ||
<Label htmlFor="manage-facility-facility-select"> | ||
Testing facility <Required /> | ||
</Label> | ||
|
||
<ComboBox | ||
name={"Facility"} | ||
id={"manage-facility-facility-select"} | ||
options={facilityOptions} | ||
onChange={(val) => onSelectFacility(val)} | ||
disabled={loading} | ||
required={true} | ||
ref={facilityRef} | ||
/> | ||
</div> | ||
<div className="desktop:grid-col-4 tablet:grid-col-4 mobile:grid-col-1"> | ||
<Button onClick={onSearch} ariaLabel="Search facility selection"> | ||
<div className="desktop:grid-col-4 tablet:grid-col-4 mobile:grid-col-1 "> | ||
<Button | ||
onClick={onSearch} | ||
disabled={manageFacilityState.facilityId === undefined} | ||
ariaLabel="Search facility selection" | ||
> | ||
Search | ||
</Button> | ||
</div> | ||
|
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.
moving this hook into a before each as recommended here