Skip to content

Commit 22aa781

Browse files
authored
fix: select filter a11y (#201)
* fix: select filter a11y * fix: updated filter list a11y * fix: remove peer dependency update
1 parent ed08069 commit 22aa781

File tree

4 files changed

+24
-9
lines changed

4 files changed

+24
-9
lines changed

package-lock.json

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@
8686
"@gravity-ui/prettier-config": "^1.1.0",
8787
"@gravity-ui/stylelint-config": "^4.0.1",
8888
"@gravity-ui/tsconfig": "^1.0.0",
89-
"@gravity-ui/uikit": "^6.9.0",
89+
"@gravity-ui/uikit": "^6.22.0",
9090
"@jest/environment": "^29.7.0",
9191
"@storybook/addon-essentials": "^8.0.5",
9292
"@storybook/addon-mdx-gfm": "^8.0.5",

src/components/FeedHeader/components/Controls/customRenders.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ type RenderSwitcherType = ({
2727
export const renderSwitcher: RenderSwitcherType =
2828
({initial, list, defaultLabel}) =>
2929
// eslint-disable-next-line react/display-name
30-
({onClick, ref, onKeyDown, open, renderClear}) => (
30+
({onClick, ref, onKeyDown, open, renderClear, popupId, activeIndex}) => (
3131
<CustomSwitcher
3232
initial={initial}
3333
defaultLabel={defaultLabel}
@@ -37,6 +37,8 @@ export const renderSwitcher: RenderSwitcherType =
3737
onKeyDown={onKeyDown}
3838
renderClear={renderClear}
3939
open={open}
40+
popupId={popupId}
41+
activeIndex={activeIndex}
4042
/>
4143
);
4244

src/components/FeedHeader/components/CustomSwitcher/CustomSwitcher.tsx

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React, {LegacyRef, useMemo} from 'react';
22

3-
import {Icon, SelectProps} from '@gravity-ui/uikit';
3+
import {Icon, SelectProps, useUniqId} from '@gravity-ui/uikit';
44

55
import {DropdownArrow} from '../../../../icons/DropdownArrow';
66
import {Close} from '../../../../icons/Close';
@@ -32,6 +32,8 @@ export const CustomSwitcher = ({
3232
onKeyDown,
3333
open,
3434
renderClear,
35+
popupId,
36+
activeIndex,
3537
}: CustomSwitcherProps) => {
3638
const itemsNames = useMemo(() => {
3739
const items = list
@@ -42,15 +44,26 @@ export const CustomSwitcher = ({
4244
}, [defaultLabel, initial, list]);
4345
const hasCounter = itemsNames.length > 1;
4446

47+
const contentElementId = useUniqId();
48+
4549
return (
4650
<div className={b('custom-switcher')} ref={controlRef as LegacyRef<HTMLDivElement>}>
51+
{/* eslint-disable-next-line jsx-a11y/role-supports-aria-props */}
4752
<button
4853
onClick={onClick}
4954
className={b('custom-switcher-element', {overlay: true})}
5055
onKeyDown={onKeyDown}
5156
aria-expanded={open}
57+
aria-labelledby={contentElementId}
58+
aria-activedescendant={
59+
activeIndex === undefined ? undefined : `${popupId}-item-${activeIndex}`
60+
}
5261
/>
53-
<div className={b('custom-switcher-element', {content: true})}>
62+
<div
63+
id={contentElementId}
64+
className={b('custom-switcher-element', {content: true})}
65+
aria-hidden
66+
>
5467
{itemsNames?.join(', ')}
5568
</div>
5669
{renderClear &&

0 commit comments

Comments
 (0)