Skip to content

Commit 9ba5d1c

Browse files
author
kkmch
committed
feat: use button tag for select control, fix arrow navigation
1 parent 5b128b2 commit 9ba5d1c

File tree

5 files changed

+21
-12
lines changed

5 files changed

+21
-12
lines changed

package-lock.json

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

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@
7878
},
7979
"peerDependencies": {
8080
"@doc-tools/transform": "^3.3.2",
81-
"@gravity-ui/page-constructor": "^4.0.0",
81+
"@gravity-ui/page-constructor": "file:gravity-ui-page-constructor-4.21.0.tgz",
8282
"@gravity-ui/uikit": "^5.1.0",
8383
"react": "^16.0.0 || ^17.0.0 || ^18.0.0"
8484
},
@@ -89,7 +89,7 @@
8989
"@commitlint/config-conventional": "^17.4.3",
9090
"@doc-tools/transform": "^3.3.2",
9191
"@gravity-ui/eslint-config": "^2.0.0",
92-
"@gravity-ui/page-constructor": "^4.20.2",
92+
"@gravity-ui/page-constructor": "file:gravity-ui-page-constructor-4.21.0.tgz",
9393
"@gravity-ui/prettier-config": "^1.0.1",
9494
"@gravity-ui/stylelint-config": "^1.0.0",
9595
"@gravity-ui/tsconfig": "^1.0.0",

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,16 @@ type RenderSwitcherType = ({
2727
export const renderSwitcher: RenderSwitcherType =
2828
({initial, list, defaultLabel}) =>
2929
// eslint-disable-next-line react/display-name
30-
({onClick, ref}) =>
30+
({onClick, ref, onKeyDown, open}) =>
3131
(
3232
<CustomSwitcher
3333
initial={initial}
3434
defaultLabel={defaultLabel}
3535
list={list}
3636
controlRef={ref}
3737
onClick={onClick}
38+
onKeyDown={onKeyDown}
39+
open={open}
3840
/>
3941
);
4042

src/components/FeedHeader/components/CustomSwitcher/CustomSwitcher.scss

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ $block: '.#{$namespace}feed-custom-switcher';
88

99
&__custom-switcher {
1010
@include text-size(body-2);
11+
@include focusable();
1112
position: relative;
1213

1314
display: flex;
@@ -18,6 +19,7 @@ $block: '.#{$namespace}feed-custom-switcher';
1819
border-radius: var(--g-border-radius-xl);
1920
width: 100%;
2021
line-height: 42px;
22+
text-align: initial;
2123

2224
// TODO delete this section after Select can customize the popup list
2325
& + .yc-popup.yc-popup_open {

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

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ export const CustomSwitcher = ({
2727
list,
2828
onClick,
2929
controlRef,
30+
onKeyDown,
31+
open,
3032
}: CustomSwitcherProps) => {
3133
const itemsNames = useMemo(() => {
3234
const items = list
@@ -38,10 +40,12 @@ export const CustomSwitcher = ({
3840
const hasCounter = itemsNames.length > 1;
3941

4042
return (
41-
<div
43+
<button
4244
className={b('custom-switcher')}
4345
onClick={onClick}
44-
ref={controlRef as LegacyRef<HTMLDivElement>}
46+
ref={controlRef as LegacyRef<HTMLButtonElement>}
47+
onKeyDown={onKeyDown}
48+
aria-expanded={open}
4549
>
4650
<div className={b('custom-switcher-element', {content: true})}>
4751
{itemsNames?.join(', ')}
@@ -54,6 +58,6 @@ export const CustomSwitcher = ({
5458
<div className={b('custom-switcher-element', {arrow: true})}>
5559
<Icon data={DropdownArrow} size={ICON_SIZE} className={b('switcher-arrow')} />
5660
</div>
57-
</div>
61+
</button>
5862
);
5963
};

0 commit comments

Comments
 (0)