Skip to content

Commit 22ad96d

Browse files
authored
fix(AnalyticalTable): add tooltip to header selection-cell (#5081)
1 parent 93092d8 commit 22ad96d

File tree

5 files changed

+31
-11
lines changed

5 files changed

+31
-11
lines changed

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

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import { cssVarToRgb, cypressPassThroughTestsFactory } from '@/cypress/support/utils';
21
import { ThemingParameters } from '@ui5/webcomponents-react-base';
32
import { useCallback, useEffect, useRef, useState } from 'react';
43
import type { AnalyticalTablePropTypes } from '../..';
@@ -14,6 +13,7 @@ import {
1413
import { AnalyticalTableSelectionMode, AnalyticalTableVisibleRowCountMode, ValueState } from '../../enums/index.js';
1514
import { useManualRowSelect } from './pluginHooks/useManualRowSelect';
1615
import { useRowDisableSelection } from './pluginHooks/useRowDisableSelection';
16+
import { cssVarToRgb, cypressPassThroughTestsFactory } from '@/cypress/support/utils';
1717

1818
const generateMoreData = (count) => {
1919
return new Array(count).fill('').map((item, index) => ({
@@ -1990,8 +1990,12 @@ describe('AnalyticalTable', () => {
19901990
);
19911991
};
19921992
cy.mount(<TestComp />);
1993-
cy.get('[data-visible-column-index="0"][data-visible-row-index="0"]').click();
1993+
cy.get('[data-visible-column-index="0"][data-visible-row-index="0"]')
1994+
.as('selAll')
1995+
.should('have.attr', 'title', 'Select All')
1996+
.click();
19941997
cy.get('@selectSpy').should('have.been.calledOnce');
1998+
cy.get('@selAll').should('have.attr', 'title', 'Deselect All');
19951999
cy.findByTestId('payload').should(
19962000
'have.text',
19972001
'{"selectedRowIds":{"0":true,"1":true,"2":true,"3":true},"selectedFlatRows":[{"id":"0"},{"id":"1"},{"id":"2"},{"id":"3"}],"allRowsSelected":true}'
@@ -2002,13 +2006,13 @@ describe('AnalyticalTable', () => {
20022006
'have.text',
20032007
'{"selectedRowIds":{"0":true,"1":true,"3":true},"selectedFlatRows":[{"id":"0"},{"id":"1"},{"id":"3"}],"allRowsSelected":false}'
20042008
);
2005-
cy.get('[data-visible-column-index="0"][data-visible-row-index="0"]').click();
2009+
cy.get('@selAll').should('have.attr', 'title', 'Select All').click();
20062010
cy.get('@selectSpy').should('have.been.calledThrice');
20072011
cy.findByTestId('payload').should(
20082012
'have.text',
20092013
'{"selectedRowIds":{"0":true,"1":true,"2":true,"3":true},"selectedFlatRows":[{"id":"0"},{"id":"1"},{"id":"2"},{"id":"3"}],"allRowsSelected":true}'
20102014
);
2011-
cy.get('[data-visible-column-index="0"][data-visible-row-index="0"]').click();
2015+
cy.get('@selAll').click();
20122016
cy.get('@selectSpy').should('have.callCount', 4);
20132017
cy.findByTestId('payload').should(
20142018
'have.text',

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ export interface ColumnHeaderProps {
5151
column: ColumnType;
5252
role: string;
5353
isFiltered?: boolean;
54+
title?: string;
5455
['aria-sort']?: AriaAttributes['aria-sort'];
5556
['aria-label']?: AriaAttributes['aria-label'];
5657
}
@@ -142,6 +143,7 @@ export const ColumnHeader = (props: ColumnHeaderProps) => {
142143
portalContainer,
143144
scaleXFactor,
144145
isFiltered,
146+
title,
145147
'aria-label': ariaLabel,
146148
'aria-sort': ariaSort,
147149
showVerticalEndBorder
@@ -260,6 +262,7 @@ export const ColumnHeader = (props: ColumnHeaderProps) => {
260262
onKeyUp={handleHeaderCellKeyUp}
261263
aria-label={ariaLabel}
262264
aria-sort={ariaSort}
265+
title={title}
263266
>
264267
<div className={classes.header} data-h-align={column.hAlign}>
265268
<Text

packages/main/src/components/AnalyticalTable/hooks/useRowSelectionColumn.tsx

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,11 @@ function getNextSelectedRowIds(rowsById) {
5959
const headerProps = (props, { instance }) => {
6060
const {
6161
flatRows,
62-
webComponentsReactProperties: { onRowSelect, selectionMode },
62+
webComponentsReactProperties: {
63+
onRowSelect,
64+
selectionMode,
65+
translatableTexts: { selectAllText, deselectAllText }
66+
},
6367
toggleAllRowsSelected,
6468
isAllRowsSelected,
6569
rowsById,
@@ -96,8 +100,7 @@ const headerProps = (props, { instance }) => {
96100
onClick(e);
97101
}
98102
};
99-
100-
return [props, { onClick, onKeyDown, style }];
103+
return [props, { onClick, onKeyDown, style, title: isAllRowsSelected ? deselectAllText : selectAllText }];
101104
}
102105
return props;
103106
};
@@ -171,11 +174,11 @@ const getCellProps = (props, { cell }) => {
171174

172175
const setToggleAllRowsSelectedProps = (props, { instance: { webComponentsReactProperties } }) => {
173176
const { classes } = webComponentsReactProperties;
174-
return [props, { className: classes.checkBox }];
177+
return [props, { className: classes.checkBox, title: undefined }];
175178
};
176179
const setToggleRowSelectedProps = (props, { instance: { webComponentsReactProperties } }) => {
177180
const { classes } = webComponentsReactProperties;
178-
return [props, { className: classes.checkBox }];
181+
return [props, { className: classes.checkBox, title: undefined }];
179182
};
180183

181184
export const useRowSelectionColumn = (hooks) => {

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,9 @@ import {
5353
GROUPED,
5454
INVALID_TABLE,
5555
SELECT_PRESS_SPACE,
56-
UNSELECT_PRESS_SPACE
56+
UNSELECT_PRESS_SPACE,
57+
SELECT_ALL,
58+
DESELECT_ALL
5759
} from '../../i18n/i18n-defaults.js';
5860
import type { CommonProps } from '../../interfaces/index.js';
5961
import { FlexBox } from '../FlexBox/index.js';
@@ -733,6 +735,8 @@ const AnalyticalTable = forwardRef<AnalyticalTableDomRef, AnalyticalTablePropTyp
733735
sortTypes: sortTypesFallback,
734736
webComponentsReactProperties: {
735737
translatableTexts: {
738+
selectAllText: i18nBundle.getText(SELECT_ALL),
739+
deselectAllText: i18nBundle.getText(DESELECT_ALL),
736740
expandA11yText: i18nBundle.getText(EXPAND_PRESS_SPACE),
737741
collapseA11yText: i18nBundle.getText(COLLAPSE_PRESS_SPACE),
738742
selectA11yText: i18nBundle.getText(SELECT_PRESS_SPACE),

packages/main/src/i18n/messagebundle.properties

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ COLLAPSE_PRESS_SPACE=To collapse the row, press the spacebar
244244
SELECT_PRESS_SPACE=To select the row, press the spacebar
245245

246246
#XACT: Aria label text for selectable table cells in selected state
247-
UNSELECT_PRESS_SPACE=To unselect the row, press the spacebar
247+
UNSELECT_PRESS_SPACE=To deselect the row, press the spacebar
248248

249249
#XACT: Aria label text for an invalid table with overlay
250250
INVALID_TABLE=Invalid Table
@@ -281,3 +281,9 @@ INDICATION_COLOR=Indication Color
281281

282282
#XACT: Invisible text for ObjectStatus empty value
283283
EMPTY_VALUE=Empty Value
284+
285+
#XACT: Tooltip for unselected "Select All" checkbox of table
286+
SELECT_ALL=Select All
287+
288+
#XACT: Tooltip for selected "Select All" checkbox of table
289+
DESELECT_ALL=Deselect All

0 commit comments

Comments
 (0)