Skip to content

Commit e77f264

Browse files
committed
fix: change selection count position and visibility, enhance accessibility support
1 parent 8c1269d commit e77f264

File tree

4 files changed

+39
-25
lines changed

4 files changed

+39
-25
lines changed

packages/pluggableWidgets/datagrid-web/src/Datagrid.editorConfig.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ export function getProperties(
7575
]);
7676
}
7777
});
78+
7879
if (values.pagination === "buttons") {
7980
hidePropertyIn(defaultProperties, values, "showNumberOfRows");
8081
} else {
@@ -169,7 +170,11 @@ function hideSelectionProperties(defaultProperties: Properties, values: Datagrid
169170
}
170171

171172
if (itemSelection !== "Multi") {
172-
hidePropertyIn(defaultProperties, values, "keepSelection");
173+
hidePropertiesIn(defaultProperties, values, [
174+
"keepSelection",
175+
"selectionCountPosition",
176+
"clearSelectionButtonLabel"
177+
]);
173178
}
174179
}
175180

packages/pluggableWidgets/datagrid-web/src/Datagrid.xml

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,22 @@
5353
<caption>Keep selection</caption>
5454
<description>If enabled, selected items will stay selected unless cleared by the user or a Nanoflow.</description>
5555
</property>
56+
<property key="selectionCountPosition" type="enumeration" defaultValue="bottom" required="true">
57+
<caption>Show selection count</caption>
58+
<description />
59+
<enumerationValues>
60+
<enumerationValue key="top">Top</enumerationValue>
61+
<enumerationValue key="bottom">Bottom</enumerationValue>
62+
<enumerationValue key="off">Off</enumerationValue>
63+
</enumerationValues>
64+
</property>
65+
<property key="clearSelectionButtonLabel" type="textTemplate" required="false">
66+
<caption>Clear selection label</caption>
67+
<description>Customize the label of the 'Clear section' button</description>
68+
<translations>
69+
<translation lang="en_US">Clear selection</translation>
70+
</translations>
71+
</property>
5672
<property key="loadingType" type="enumeration" defaultValue="spinner" required="true">
5773
<caption>Loading type</caption>
5874
<description />
@@ -244,22 +260,6 @@
244260
<enumerationValue key="both">Both</enumerationValue>
245261
</enumerationValues>
246262
</property>
247-
<property key="selectionCountPosition" type="enumeration" defaultValue="bottom" required="true">
248-
<caption>Show selection count</caption>
249-
<description />
250-
<enumerationValues>
251-
<enumerationValue key="top">Top</enumerationValue>
252-
<enumerationValue key="bottom">Bottom</enumerationValue>
253-
<enumerationValue key="off">Off</enumerationValue>
254-
</enumerationValues>
255-
</property>
256-
<property key="clearSelectionButtonLabel" type="textTemplate" required="false">
257-
<caption>Clear selection label</caption>
258-
<description>Customize the label of the 'Clear section' button</description>
259-
<translations>
260-
<translation lang="en_US">Clear selection</translation>
261-
</translations>
262-
</property>
263263
<property key="loadMoreButtonCaption" type="textTemplate" required="false">
264264
<caption>Load more caption</caption>
265265
<description />

packages/pluggableWidgets/datagrid-web/src/components/SelectionCounter.tsx

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,20 @@ export const SelectionCounter = observer(function SelectionCounter({
1414

1515
const containerClass = location === "top" ? "widget-datagrid-tb-start" : "widget-datagrid-pb-start";
1616

17+
const clearButtonAriaLabel = `${selectionCountStore.clearButtonLabel} (${selectionCountStore.selectedCount} selected)`;
18+
1719
return (
1820
<If condition={selectionCountStore.displayCount !== ""}>
1921
<div className={containerClass}>
20-
<span className="widget-datagrid-selection-count">{selectionCountStore.displayCount}</span>&nbsp;|&nbsp;
21-
<button className="widget-datagrid-clear-selection" onClick={selectActionHelper.onClearSelection}>
22+
<span className="widget-datagrid-selection-count" aria-live="polite" aria-atomic="true">
23+
{selectionCountStore.displayCount}
24+
</span>
25+
&nbsp;|&nbsp;
26+
<button
27+
className="widget-datagrid-clear-selection"
28+
onClick={selectActionHelper.onClearSelection}
29+
aria-label={clearButtonAriaLabel}
30+
>
2231
{selectionCountStore.clearButtonLabel}
2332
</button>
2433
</div>

packages/pluggableWidgets/datagrid-web/typings/DatagridProps.d.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ export type ItemSelectionMethodEnum = "checkbox" | "rowClick";
1111

1212
export type ItemSelectionModeEnum = "toggle" | "clear";
1313

14+
export type SelectionCountPositionEnum = "top" | "bottom" | "off";
15+
1416
export type LoadingTypeEnum = "spinner" | "skeleton";
1517

1618
export type ShowContentAsEnum = "attribute" | "dynamicText" | "customContent";
@@ -53,8 +55,6 @@ export type ShowPagingButtonsEnum = "always" | "auto";
5355

5456
export type PagingPositionEnum = "bottom" | "top" | "both";
5557

56-
export type SelectionCountPositionEnum = "top" | "bottom" | "off";
57-
5858
export type ShowEmptyPlaceholderEnum = "none" | "custom";
5959

6060
export type OnClickTriggerEnum = "single" | "double";
@@ -98,6 +98,8 @@ export interface DatagridContainerProps {
9898
itemSelectionMode: ItemSelectionModeEnum;
9999
showSelectAllToggle: boolean;
100100
keepSelection: boolean;
101+
selectionCountPosition: SelectionCountPositionEnum;
102+
clearSelectionButtonLabel?: DynamicValue<string>;
101103
loadingType: LoadingTypeEnum;
102104
refreshIndicator: boolean;
103105
columns: ColumnsType[];
@@ -107,8 +109,6 @@ export interface DatagridContainerProps {
107109
showPagingButtons: ShowPagingButtonsEnum;
108110
showNumberOfRows: boolean;
109111
pagingPosition: PagingPositionEnum;
110-
selectionCountPosition: SelectionCountPositionEnum;
111-
clearSelectionButtonLabel?: DynamicValue<string>;
112112
loadMoreButtonCaption?: DynamicValue<string>;
113113
showEmptyPlaceholder: ShowEmptyPlaceholderEnum;
114114
emptyPlaceholder?: ReactNode;
@@ -152,6 +152,8 @@ export interface DatagridPreviewProps {
152152
itemSelectionMode: ItemSelectionModeEnum;
153153
showSelectAllToggle: boolean;
154154
keepSelection: boolean;
155+
selectionCountPosition: SelectionCountPositionEnum;
156+
clearSelectionButtonLabel: string;
155157
loadingType: LoadingTypeEnum;
156158
refreshIndicator: boolean;
157159
columns: ColumnsPreviewType[];
@@ -161,8 +163,6 @@ export interface DatagridPreviewProps {
161163
showPagingButtons: ShowPagingButtonsEnum;
162164
showNumberOfRows: boolean;
163165
pagingPosition: PagingPositionEnum;
164-
selectionCountPosition: SelectionCountPositionEnum;
165-
clearSelectionButtonLabel: string;
166166
loadMoreButtonCaption: string;
167167
showEmptyPlaceholder: ShowEmptyPlaceholderEnum;
168168
emptyPlaceholder: { widgetCount: number; renderer: ComponentType<{ children: ReactNode; caption?: string }> };

0 commit comments

Comments
 (0)