Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
10 changes: 5 additions & 5 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@
"@gravity-ui/prettier-config": "^1.1.0",
"@gravity-ui/stylelint-config": "^4.0.1",
"@gravity-ui/tsconfig": "^1.0.0",
"@gravity-ui/uikit": "^6.9.0",
"@gravity-ui/uikit": "^6.22.0",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

make sure nothing is broken, because we have some overrides over uikit in this repo

"@jest/environment": "^29.7.0",
"@storybook/addon-essentials": "^8.0.5",
"@storybook/addon-mdx-gfm": "^8.0.5",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ type RenderSwitcherType = ({
export const renderSwitcher: RenderSwitcherType =
({initial, list, defaultLabel}) =>
// eslint-disable-next-line react/display-name
({onClick, ref, onKeyDown, open, renderClear}) => (
({onClick, ref, onKeyDown, open, renderClear, popupId, activeIndex}) => (
<CustomSwitcher
initial={initial}
defaultLabel={defaultLabel}
Expand All @@ -37,6 +37,8 @@ export const renderSwitcher: RenderSwitcherType =
onKeyDown={onKeyDown}
renderClear={renderClear}
open={open}
popupId={popupId}
activeIndex={activeIndex}
/>
);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, {LegacyRef, useMemo} from 'react';

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

import {DropdownArrow} from '../../../../icons/DropdownArrow';
import {Close} from '../../../../icons/Close';
Expand Down Expand Up @@ -32,6 +32,8 @@ export const CustomSwitcher = ({
onKeyDown,
open,
renderClear,
popupId,
activeIndex,
}: CustomSwitcherProps) => {
const itemsNames = useMemo(() => {
const items = list
Expand All @@ -42,15 +44,26 @@ export const CustomSwitcher = ({
}, [defaultLabel, initial, list]);
const hasCounter = itemsNames.length > 1;

const contentElementId = useUniqId();

return (
<div className={b('custom-switcher')} ref={controlRef as LegacyRef<HTMLDivElement>}>
{/* eslint-disable-next-line jsx-a11y/role-supports-aria-props */}
<button
onClick={onClick}
className={b('custom-switcher-element', {overlay: true})}
onKeyDown={onKeyDown}
aria-expanded={open}
aria-labelledby={contentElementId}
aria-activedescendant={
activeIndex === undefined ? undefined : `${popupId}-item-${activeIndex}`
}
/>
<div className={b('custom-switcher-element', {content: true})}>
<div
id={contentElementId}
className={b('custom-switcher-element', {content: true})}
aria-hidden
>
{itemsNames?.join(', ')}
</div>
{renderClear &&
Expand Down