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

Add aria-expanded and aria-controls to Toggle #2202

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
0cc87eb
Add aria-expanded and aria-controls to Toggle
RoyEJohnson Mar 25, 2024
a9d1a8e
Merge branch 'main' into add-label-and-expanded-attributes-to-chapter…
staxly[bot] Apr 1, 2024
023a438
Merge branch 'main' into add-label-and-expanded-attributes-to-chapter…
staxly[bot] Apr 9, 2024
9c946ac
Merge branch 'main' into add-label-and-expanded-attributes-to-chapter…
staxly[bot] Apr 9, 2024
075edef
Merge branch 'main' into add-label-and-expanded-attributes-to-chapter…
staxly[bot] Apr 10, 2024
c8dab72
Merge branch 'main' into add-label-and-expanded-attributes-to-chapter…
staxly[bot] Apr 10, 2024
d93374c
Merge branch 'main' into add-label-and-expanded-attributes-to-chapter…
staxly[bot] Apr 11, 2024
9eecef2
Merge branch 'main' into add-label-and-expanded-attributes-to-chapter…
staxly[bot] Apr 11, 2024
f407748
Merge branch 'main' into add-label-and-expanded-attributes-to-chapter…
staxly[bot] Apr 19, 2024
46ed309
Merge branch 'main' into add-label-and-expanded-attributes-to-chapter…
staxly[bot] Apr 22, 2024
9a8f924
Merge branch 'main' into add-label-and-expanded-attributes-to-chapter…
staxly[bot] Apr 23, 2024
7d527fe
Merge branch 'main' into add-label-and-expanded-attributes-to-chapter…
staxly[bot] Apr 23, 2024
a376fb2
Merge branch 'main' into add-label-and-expanded-attributes-to-chapter…
staxly[bot] May 1, 2024
50ddfa1
Merge branch 'main' into add-label-and-expanded-attributes-to-chapter…
staxly[bot] May 2, 2024
c766b3d
Merge branch 'main' into add-label-and-expanded-attributes-to-chapter…
staxly[bot] May 2, 2024
3125bc4
Merge branch 'main' into add-label-and-expanded-attributes-to-chapter…
staxly[bot] May 2, 2024
2aceee1
Merge branch 'main' into add-label-and-expanded-attributes-to-chapter…
staxly[bot] May 3, 2024
7999697
Merge branch 'main' into add-label-and-expanded-attributes-to-chapter…
staxly[bot] May 3, 2024
c8916aa
Merge branch 'main' into add-label-and-expanded-attributes-to-chapter…
staxly[bot] May 6, 2024
076a3bb
Merge branch 'main' into add-label-and-expanded-attributes-to-chapter…
staxly[bot] May 6, 2024
365bb19
Merge branch 'main' into add-label-and-expanded-attributes-to-chapter…
staxly[bot] May 7, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/app/content/__snapshots__/routes.spec.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,7 @@ Array [
className="c2 c3 c4"
>
<button
aria-expanded={false}
aria-label="Change text size"
className="c5 c6 c7 c8"
data-analytics-label="Change text size"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1627,6 +1627,7 @@ exports[`text resizer opens menu when clicking menu button 1`] = `
className="c13 c14 c15"
>
<button
aria-expanded={true}
aria-label="Change text size"
className="c16 c17 c18 c19"
data-analytics-label="Change text size"
Expand Down Expand Up @@ -1771,6 +1772,7 @@ exports[`text resizer opens menu when clicking menu button 1`] = `
className="c13 c14 c15"
>
<button
aria-expanded={false}
aria-label="Change text size"
className="c16 c28 c18 c19"
data-analytics-label="Change text size"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ exports[`AssignedTopBar renders 1`] = `
className="c2 c3 c4"
>
<button
aria-expanded={false}
aria-label="Change text size"
className="c5 c6 c7 c8"
data-analytics-label="Change text size"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3205,6 +3205,7 @@ li[aria-label="Current Page"] .c60 {
className="c23 c24 c25"
>
<button
aria-expanded={false}
aria-label="Change text size"
className="c26 c27 c28 c29"
data-analytics-label="Change text size"
Expand Down Expand Up @@ -3301,6 +3302,7 @@ li[aria-label="Current Page"] .c60 {
className="c23 c24 c25"
>
<button
aria-expanded={false}
aria-label="Change text size"
className="c26 c27 c28 c29"
data-analytics-label="Change text size"
Expand Down Expand Up @@ -7748,6 +7750,7 @@ li[aria-label="Current Page"] .c60 {
className="c23 c24 c25"
>
<button
aria-expanded={false}
aria-label="Change text size"
className="c26 c27 c28 c29"
data-analytics-label="Change text size"
Expand Down Expand Up @@ -7844,6 +7847,7 @@ li[aria-label="Current Page"] .c60 {
className="c23 c24 c25"
>
<button
aria-expanded={false}
aria-label="Change text size"
className="c26 c27 c28 c29"
data-analytics-label="Change text size"
Expand Down
3 changes: 2 additions & 1 deletion src/app/content/components/popUp/ChapterFilter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ interface ChapterFilterProps {
selectedLocationFilters: Set<string>;
multiselect: boolean;
setFilters: (filters: FiltersChange<LinkedArchiveTreeNode>) => void;
id: string;
}

// tslint:disable-next-line:variable-name
Expand Down Expand Up @@ -107,7 +108,7 @@ const ChapterFilter = (props: ChapterFilterProps) => {
const hasFiltersWithChildren = Boolean(values.find((filter) => filter.children));
const sectionChunks = hasFiltersWithChildren ? [values] : chunk(values);

return <div className={props.className} tabIndex={-1}>
return <div className={props.className} tabIndex={-1} id={props.id}>
{props.multiselect
? (
<AllOrNone
Expand Down
1 change: 1 addition & 0 deletions src/app/content/components/popUp/ColorFilter.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ describe('ColorFilter', () => {
]),
styles: highlightStyles,
updateSummaryFilters: jest.fn(),
id: 'color-filter',
};
});

Expand Down
4 changes: 3 additions & 1 deletion src/app/content/components/popUp/ColorFilter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export interface ColorFilterProps {
colorFiltersWithContent: Set<HighlightColorEnum>;
updateSummaryFilters: (change: FiltersChange<HighlightColorEnum>) => void;
labelKey: (label: HighlightColorEnum) => string;
id: string;
}

// tslint:disable-next-line:variable-name
Expand All @@ -38,6 +39,7 @@ const ColorFilter = ({
colorFiltersWithContent,
updateSummaryFilters,
labelKey,
id,
}: ColorFilterProps) => {

const setSelectedColors = (change: FiltersChange<HighlightColorEnum>) => {
Expand All @@ -52,7 +54,7 @@ const ColorFilter = ({
}
};

return <div className={className} tabIndex={-1}>
return <div className={className} tabIndex={-1} id={id}>
<AllOrNone
onNone={() => setSelectedColors({ remove: Array.from(colorFiltersWithContent), new: [] })}
onAll={() => setSelectedColors({ remove: [], new: Array.from(colorFiltersWithContent) })}
Expand Down
50 changes: 38 additions & 12 deletions src/app/content/components/popUp/Filters.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,26 +35,50 @@ interface ToggleProps {
isOpen: boolean;
ariaLabelId: string;
showAngleIcon: boolean;
controlsId: string;
}
// tslint:disable-next-line:variable-name
const Toggle = styled(React.forwardRef<HTMLButtonElement, ToggleProps>(
({label, isOpen, ariaLabelId, showAngleIcon = true, showLabel = true, toggleChildren, ...props}, ref) => (
<PlainButton ref={ref} {...props} aria-label={useIntl().formatMessage({id: ariaLabelId}, {filter: label})}>
<div tabIndex={-1}>
{showLabel && label}
{toggleChildren}
{showAngleIcon && <AngleIcon direction={isOpen ? 'up' : 'down'} />}
</div>
</PlainButton>
const Toggle = styled(
React.forwardRef<HTMLButtonElement, ToggleProps>(
(
{
label,
isOpen,
ariaLabelId,
showAngleIcon = true,
showLabel = true,
toggleChildren,
controlsId,
...props
},
ref
) => (
<PlainButton
ref={ref}
{...props}
aria-label={useIntl().formatMessage(
{ id: ariaLabelId },
{ filter: label }
)}
aria-expanded={isOpen}
aria-controls={controlsId}
>
<div tabIndex={-1}>
{showLabel && label}
{toggleChildren}
{showAngleIcon && <AngleIcon direction={isOpen ? 'up' : 'down'} />}
</div>
</PlainButton>
)
)
))`
)`
position: relative;
border-left: ${filters.border}rem solid transparent;
border-right: ${filters.border}rem solid transparent;
${(props: ToggleProps) => props.isOpen
? css`
z-index: 2;
box-shadow: 0 0 0.6rem 0 rgba(0,0,0,0.2);
box-shadow: 0 0 0.6rem 0 rgba(0, 0, 0, 0.2);
clip-path: inset(0 -0.6rem 0px -0.6rem);
background-color: ${theme.color.white};
border-left: ${filters.border}rem solid ${theme.color.neutral.formBorder};
Expand Down Expand Up @@ -85,6 +109,7 @@ type FilterDropdownProps = {
dataAnalyticsLabel: string;
showAngleIcon?: boolean;
toggleChildren?: JSX.Element;
controlsId: string;
} & Partial<TabHiddenDropdownProps>;

// tslint:disable-next-line:variable-name
Expand All @@ -97,7 +122,8 @@ React.PropsWithChildren<FilterDropdownProps>) => (
toggleChildren={toggleChildren}
ariaLabelId={ariaLabelId}
data-analytics-label={dataAnalyticsLabel}
showAngleIcon={props.showAngleIcon} />}
showAngleIcon={props.showAngleIcon}
controlsId={props.controlsId} />}
transparentTab={false}
{...props}
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -478,6 +478,7 @@ input:checked + .c8 .c10 {

<div
className="c0"
id="color-filter"
tabIndex={-1}
>
<div
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,8 @@ exports[`Filters matches snapshot 1`] = `
className="c2 c3 c4"
>
<button
aria-controls="summary-filter-chapter"
aria-expanded={false}
aria-label="Filter highlights by Chapter"
className="c5 c6 c7 c8"
data-analytics-label="Filter highlights by Chapter"
Expand Down Expand Up @@ -379,6 +381,8 @@ exports[`Filters matches snapshot 1`] = `
className="c2 c3 c4"
>
<button
aria-controls="summary-filter-color"
aria-expanded={false}
aria-label="Filter highlights by Color"
className="c5 c6 c7 c8"
data-analytics-label="Filter highlights by Color"
Expand Down Expand Up @@ -1000,6 +1004,8 @@ exports[`Filters matches snapshot when open color filters 1`] = `
className="c2 c3 c4"
>
<button
aria-controls="summary-filter-chapter"
aria-expanded={false}
aria-label="Filter highlights by Chapter"
className="c5 c6 c7 c8"
data-analytics-label="Filter highlights by Chapter"
Expand Down Expand Up @@ -1030,6 +1036,8 @@ exports[`Filters matches snapshot when open color filters 1`] = `
className="c2 c3 c4"
>
<button
aria-controls="summary-filter-color"
aria-expanded={true}
aria-label="Filter highlights by Color"
className="c5 c11 c7 c8"
data-analytics-label="Filter highlights by Color"
Expand Down Expand Up @@ -1057,6 +1065,7 @@ exports[`Filters matches snapshot when open color filters 1`] = `
</button>
<div
colorFiltersWithContent={Set {}}
id="summary-filter-color"
labelKey={[Function]}
mock-color-filter={true}
selectedColorFilters={Set {}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,15 +81,18 @@ export default () =>
label='i18n:highlighting:filters:chapters'
ariaLabelId='i18n:highlighting:filters:filter-by:aria-label'
dataAnalyticsLabel='Filter highlights by Chapter'
controlsId='summary-filter-chapter'
>
<ConnectedChapterFilter multiselect={true} />
<ConnectedChapterFilter multiselect={true} id='summary-filter-chapter' />
</FilterDropdown>
<FilterDropdown
label='i18n:highlighting:filters:colors'
ariaLabelId='i18n:highlighting:filters:filter-by:aria-label'
dataAnalyticsLabel='Filter highlights by Color'
controlsId='summary-filter-color'
>
<ConnectedColorFilter
id='summary-filter-color'
styles={highlightStyles}
labelKey={(label: HighlightColorEnum) => `i18n:highlighting:colors:${label}`}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -835,6 +835,8 @@ input:checked + .c21 .c22 {
className="c2 c3 c4"
>
<button
aria-controls="summary-filter-chapter"
aria-expanded={true}
aria-label="Filter highlights by Chapter"
className="c5 c6 c7 c8"
data-analytics-label="Filter highlights by Chapter"
Expand Down Expand Up @@ -862,6 +864,7 @@ input:checked + .c21 .c22 {
</button>
<div
className="c11"
id="summary-filter-chapter"
tabIndex={-1}
>
<div
Expand Down Expand Up @@ -892,6 +895,8 @@ input:checked + .c21 .c22 {
className="c2 c3 c4"
>
<button
aria-controls="summary-filter-color"
aria-expanded={true}
aria-label="Filter highlights by Color"
className="c5 c6 c7 c8"
data-analytics-label="Filter highlights by Color"
Expand Down Expand Up @@ -919,6 +924,7 @@ input:checked + .c21 .c22 {
</button>
<div
className="c17"
id="summary-filter-color"
tabIndex={-1}
>
<div
Expand Down
2 changes: 2 additions & 0 deletions src/app/content/practiceQuestions/components/Filters.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,10 @@ export default () => {
dataAnalyticsLabel='Filter PQ by Chapter & Section'
open={open}
setOpen={(isOpen: boolean) => setOpen(isOpen)}
controlsId='practice-filter-chapter'
>
<StyledChapterFilters
id='practice-filter-chapter'
locationFilters={locationFilters}
selectedLocationFilters={selectedLocationFilters}
setFilters={setFilters}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,8 @@ exports[`Filters ChapterFilter matches snapshot when it is closed 1`] = `
className="c2 c3 c4"
>
<button
aria-controls="practice-filter-chapter"
aria-expanded={false}
aria-label="Filter PQ by Chapter & Section"
className="c5 c6 c7 c8"
data-analytics-label="Filter PQ by Chapter & Section"
Expand Down Expand Up @@ -557,6 +559,8 @@ exports[`Filters ChapterFilter matches snapshot when open with selected section
className="c2 c3 c4"
>
<button
aria-controls="practice-filter-chapter"
aria-expanded={true}
aria-label="Filter PQ by Chapter & Section"
className="c5 c6 c7 c8"
data-analytics-label="Filter PQ by Chapter & Section"
Expand Down Expand Up @@ -584,6 +588,7 @@ exports[`Filters ChapterFilter matches snapshot when open with selected section
</button>
<div
className="c12"
id="practice-filter-chapter"
tabIndex={-1}
>
<div
Expand Down Expand Up @@ -1054,6 +1059,8 @@ exports[`Filters ChapterFilter matches snapshot when open without selected secti
className="c2 c3 c4"
>
<button
aria-controls="practice-filter-chapter"
aria-expanded={true}
aria-label="Filter PQ by Chapter & Section"
className="c5 c6 c7 c8"
data-analytics-label="Filter PQ by Chapter & Section"
Expand Down Expand Up @@ -1081,6 +1088,7 @@ exports[`Filters ChapterFilter matches snapshot when open without selected secti
</button>
<div
className="c12"
id="practice-filter-chapter"
tabIndex={-1}
>
<div
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -470,6 +470,8 @@ exports[`PracticeQuestions renders practice questions modal if it is open 1`] =
className="c9 c10 c11"
>
<button
aria-controls="practice-filter-chapter"
aria-expanded={false}
aria-label="Filter PQ by Chapter & Section"
className="c12 c13 c14 c15"
data-analytics-label="Filter PQ by Chapter & Section"
Expand Down
4 changes: 4 additions & 0 deletions src/app/content/studyGuides/components/Filters.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,10 @@ export default () => {
label='i18n:highlighting:filters:chapters'
ariaLabelId='i18n:studyguides:popup:filters:filter-by:aria-label'
dataAnalyticsLabel='Filter study guides by Chapter'
controlsId='guide-filter-chapter'
>
<ConnectedChapterFilter
id='guide-filter-chapter'
disabled={userLoggedOut}
multiselect={true}
setFilters={(change: FiltersChange<LinkedArchiveTreeNode>) =>
Expand All @@ -136,8 +138,10 @@ export default () => {
label='i18n:highlighting:filters:colors'
ariaLabelId='i18n:studyguides:popup:filters:filter-by:aria-label'
dataAnalyticsLabel='Filter study guides by Color'
controlsId='guide-filter-color'
>
<ConnectedColorFilter
id='guide-filter-color'
disabled={userLoggedOut}
styles={highlightStyles}
labelKey={(label: HighlightColorEnum) => `i18n:studyguides:popup:filters:${label}`}
Expand Down
Loading
Loading