Skip to content

Commit 377f4c2

Browse files
authored
fix(AnalyticalTable): improve screen reader announcement for filter input (#7300)
Fixes #7298
1 parent 980449e commit 377f4c2

File tree

3 files changed

+36
-7
lines changed

3 files changed

+36
-7
lines changed

packages/main/src/components/AnalyticalTable/defaults/Column/ColumnHeaderModal.tsx

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import iconGroup from '@ui5/webcomponents-icons/dist/group-2.js';
99
import iconSortAscending from '@ui5/webcomponents-icons/dist/sort-ascending.js';
1010
import iconSortDescending from '@ui5/webcomponents-icons/dist/sort-descending.js';
1111
import { enrichEventWithDetails, useI18nBundle } from '@ui5/webcomponents-react-base';
12-
import { useEffect, useMemo, useRef } from 'react';
12+
import { useEffect, useId, useMemo, useRef } from 'react';
1313
import { FlexBoxAlignItems } from '../../../../enums/FlexBoxAlignItems.js';
1414
import { TextAlign } from '../../../../enums/TextAlign.js';
1515
import {
@@ -31,20 +31,21 @@ import { Popover } from '../../../../webComponents/Popover/index.js';
3131
import { Text } from '../../../../webComponents/Text/index.js';
3232
import { FlexBox } from '../../../FlexBox/index.js';
3333
import type { TableInstanceWithPopoverProps } from '../../types/index.js';
34+
import { RenderColumnTypes } from '../../types/index.js';
3435

3536
export const ColumnHeaderModal = (instance: TableInstanceWithPopoverProps) => {
3637
const { setOpen, openerRef } = instance.popoverProps;
3738
const { column, state, webComponentsReactProperties } = instance;
3839
const { isRtl, groupBy } = state;
3940
const { onGroup, onSort, classes: classNames } = webComponentsReactProperties;
41+
const uniqueId = useId();
4042

4143
const showFilter = column.canFilter;
4244
const showGroup = column.canGroupBy;
4345
const showSort = column.canSort;
4446

4547
const ref = useRef<PopoverDomRef>(null);
4648
const listRef = useRef(null);
47-
const { Filter } = column;
4849

4950
const i18nBundle = useI18nBundle('@ui5/webcomponents-react');
5051

@@ -231,10 +232,14 @@ export const ColumnHeaderModal = (instance: TableInstanceWithPopoverProps) => {
231232
style={{
232233
fontSize: filterStyles.fontSize
233234
}}
235+
id={`${uniqueId}-filter-text`}
234236
>
235237
{filterText}
236238
</Text>
237-
<Filter column={column} popoverRef={ref} />
239+
{column.render(RenderColumnTypes.Filter, {
240+
accessibleNameRef: `${uniqueId}-filter-text`,
241+
popoverRef: ref
242+
})}
238243
</FlexBox>
239244
</ListItemCustom>
240245
)}

packages/main/src/components/AnalyticalTable/defaults/FilterComponent/index.tsx

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import type { InputPropTypes } from '../../../../webComponents/Input/index.js';
44
import { Input } from '../../../../webComponents/Input/index.js';
55
import type { FilterProps } from '../../types/index.js';
66

7-
export const DefaultFilterComponent = ({ column }: FilterProps) => {
7+
export const DefaultFilterComponent = ({ column, accessibleNameRef }: FilterProps) => {
88
const handleInput: InputPropTypes['onInput'] = useCallback(
99
(e) => {
1010
// Setting the filter to `undefined` removes it
@@ -19,7 +19,15 @@ export const DefaultFilterComponent = ({ column }: FilterProps) => {
1919
}
2020
};
2121

22-
return <Input onInput={handleInput} value={column.filterValue ?? ''} showClearIcon onKeyDown={handleKeyDown} />;
22+
return (
23+
<Input
24+
onInput={handleInput}
25+
value={column.filterValue ?? ''}
26+
showClearIcon
27+
onKeyDown={handleKeyDown}
28+
accessibleNameRef={accessibleNameRef}
29+
/>
30+
);
2331
};
2432

2533
DefaultFilterComponent.displayName = 'DefaultFilterComponent';

packages/main/src/components/AnalyticalTable/types/index.ts

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,15 @@
11
import type { ScrollToOptions } from '@tanstack/react-virtual';
22
import type ValueState from '@ui5/webcomponents-base/dist/types/ValueState.js';
3-
import type { ComponentType, DependencyList, Dispatch, MutableRefObject, ReactNode, Ref, SetStateAction } from 'react';
3+
import type {
4+
ComponentType,
5+
DependencyList,
6+
Dispatch,
7+
MutableRefObject,
8+
ReactNode,
9+
Ref,
10+
RefObject,
11+
SetStateAction
12+
} from 'react';
413
import type {
514
AnalyticalTablePopinDisplay,
615
AnalyticalTableScaleWidthMode,
@@ -341,7 +350,14 @@ export interface TableInstanceWithPopoverProps extends TableInstance {
341350

342351
export interface FilterProps {
343352
column: ColumnType;
344-
popoverRef: MutableRefObject<PopoverDomRef>;
353+
/**
354+
* `Popover` DOM RefObject
355+
*/
356+
popoverRef: RefObject<PopoverDomRef>;
357+
/**
358+
* `accessibleNameRef` for filter `Input`
359+
*/
360+
accessibleNameRef: string;
345361
}
346362

347363
export interface AnalyticalTableColumnDefinition {

0 commit comments

Comments
 (0)