Skip to content

Commit

Permalink
fix: table and tree select a11y
Browse files Browse the repository at this point in the history
  • Loading branch information
Kezhik Kyzyl-ool committed Mar 4, 2024
1 parent 2cb4b67 commit 7759f5e
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import {TextInput} from '../../controls';
import {Select, getSelectFilteredOptions, isSelectGroupTitle, useSelectOptions} from '../index';
import type {SelectOption, SelectProps} from '../index';

const title = 'Select example with useSelectOptions hook';

export const UseSelectOptionsShowcase = () => {
const [value, setValue] = React.useState<string[]>([]);
const [filter, setFilter] = React.useState('');
Expand Down Expand Up @@ -110,6 +112,7 @@ export const UseSelectOptionsShowcase = () => {
renderFilter={renderFilter}
onFilterChange={setFilter}
onUpdate={setValue}
title={title}
/>
);
};
2 changes: 1 addition & 1 deletion src/components/Table/__stories__/Table.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ const WithTableActionsTemplate: StoryFn<TableProps<DataItem>> = (args) => {
}

const items = ['action 1', 'action 2', 'action 3'];
return <TreeSelect items={items} size="s" />;
return <TreeSelect items={items} size="s" title={'Actions select example'} />;
}}
/>
</React.Fragment>
Expand Down
2 changes: 2 additions & 0 deletions src/components/TreeSelect/TreeSelect.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ export const TreeSelect = React.forwardRef(function TreeSelect<T>(
renderContainer = TreeListContainer,
onItemClick,
placement,
title,
} = props;

const mobile = useMobile();
Expand Down Expand Up @@ -203,6 +204,7 @@ export const TreeSelect = React.forwardRef(function TreeSelect<T>(
value,
id: treeSelectId,
activeItemId: listState.activeItemId,
title,
};

const togglerNode = renderControl ? (
Expand Down
5 changes: 5 additions & 0 deletions src/components/TreeSelect/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export type TreeSelectRenderControlProps = {
value: ListItemId[];
id: string;
activeItemId?: ListItemId;
title?: string;
};

export type TreeSelectRenderItem<T, P extends {} = {}> = (props: {
Expand Down Expand Up @@ -108,6 +109,10 @@ interface TreeSelectBaseProps<T> extends QAProps, Partial<Omit<ListState, 'selec
onItemClick?:
| 'disabled'
| ((data: T, content: OverrideItemContext, defaultClickCallback: () => void) => void);
/**
* Control's title attribute value
*/
title?: string;
}

type TreeSelectKnownProps<T> = TreeSelectBaseProps<T> & {
Expand Down

0 comments on commit 7759f5e

Please sign in to comment.