Skip to content

Commit cabbc57

Browse files
committed
add ios workaround
1 parent 50826fa commit cabbc57

File tree

5 files changed

+32
-8
lines changed

5 files changed

+32
-8
lines changed

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

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,7 @@ export const Cell = (props: CellInstance) => {
1818
title={cellContent}
1919
className={webComponentsReactProperties.classes.tableText}
2020
data-column-id-cell-text={column.id}
21-
//todo: VoiceOver announces blank because of `aria-hidden` although `aria-label` is set on the `gridcell` element - this is a known bug and there's no workaround
22-
// options:
23-
// - remove it and accept duplicate announcements
24-
// - keep it and accept blank announcements
25-
// - remove it and don't add the aria-label on the focused cell, which will lead to the `cellContent` being announced last
21+
// VoiceOver announces blank because of `aria-hidden` although `aria-labelledby` is set on the `gridcell` element - this is a known bug and there's no workaround
2622
aria-hidden="true"
2723
>
2824
{cellContent}

packages/main/src/components/AnalyticalTable/hooks/useA11y.ts

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,22 @@ interface UpdatedCellProptypes {
1616
const setCellProps = (cellProps, { cell, instance }: { cell: TableInstance['cell']; instance: TableInstance }) => {
1717
const { column, row, value } = cell;
1818
const columnIndex = instance.visibleColumns.findIndex(({ id }) => id === column.id);
19-
const { alwaysShowSubComponent, renderRowSubComponent, selectionMode, selectionBehavior, a11yElementIds, uniqueId } =
20-
instance.webComponentsReactProperties;
19+
const {
20+
alwaysShowSubComponent,
21+
renderRowSubComponent,
22+
selectionMode,
23+
selectionBehavior,
24+
a11yElementIds,
25+
uniqueId,
26+
canUseVoiceOver,
27+
} = instance.webComponentsReactProperties;
28+
2129
const updatedCellProps: UpdatedCellProptypes = {
2230
// aria index is 1 based, not 0
2331
'aria-colindex': columnIndex + 1,
2432
role: 'gridcell',
2533
// header label
26-
'aria-labelledby': `${uniqueId}${column.id} ${uniqueId}${column.id}${row.id}`,
34+
'aria-labelledby': `${uniqueId}${column.id}${row.id}` + (canUseVoiceOver ? ` ${uniqueId}${column.id}` : ''),
2735
};
2836

2937
const RowSubComponent = typeof renderRowSubComponent === 'function' ? renderRowSubComponent(row) : undefined;
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import { isIOS, isMac } from '@ui5/webcomponents-react-base/Device';
2+
import { useEffect, useState } from 'react';
3+
4+
/**
5+
* SSR ready check for macOS or iOS (Apple VoiceOver support).
6+
*/
7+
export function useCanUseVoiceOver() {
8+
const [canUseVoiceOver, setCanUseVoiceOver] = useState(false);
9+
10+
useEffect(() => {
11+
setCanUseVoiceOver(isIOS() || isMac());
12+
}, []);
13+
14+
return canUseVoiceOver;
15+
}

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ import { TablePlaceholder } from './defaults/LoadingComponent/TablePlaceholder.j
6363
import { DefaultNoDataComponent } from './defaults/NoDataComponent/index.js';
6464
import { useA11y } from './hooks/useA11y.js';
6565
import { useAutoResize } from './hooks/useAutoResize.js';
66+
import { useCanUseVoiceOver } from './hooks/useCanUseVoiceOver.js';
6667
import { useColumnsDeps } from './hooks/useColumnsDeps.js';
6768
import { useColumnDragAndDrop } from './hooks/useDragAndDrop.js';
6869
import { useDynamicColumnWidths } from './hooks/useDynamicColumnWidths.js';
@@ -195,6 +196,7 @@ const AnalyticalTable = forwardRef<AnalyticalTableDomRef, AnalyticalTablePropTyp
195196
const isInitialized = useRef(false);
196197
const fontsReady = useFontsReady();
197198
const isFirefox = useIsFirefox();
199+
const canUseVoiceOver = useCanUseVoiceOver();
198200

199201
const alwaysShowSubComponent =
200202
subComponentsBehavior === AnalyticalTableSubComponentsBehavior.Visible ||
@@ -268,6 +270,7 @@ const AnalyticalTable = forwardRef<AnalyticalTableDomRef, AnalyticalTablePropTyp
268270
},
269271
alternateRowColor,
270272
alwaysShowSubComponent,
273+
canUseVoiceOver,
271274
classes: classNames,
272275
fontsReady,
273276
highlightField,

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,9 @@ export interface TableInstance {
212212
}
213213

214214
export interface WCRPropertiesType {
215+
canUseVoiceOver: boolean;
215216
fontsReady: boolean;
217+
isFirefox: boolean;
216218
selectionMode: AnalyticalTablePropTypes['selectionMode'];
217219
onRowSelect?: AnalyticalTablePropTypes['onRowSelect'];
218220
a11yElementIds: {

0 commit comments

Comments
 (0)