Skip to content

Commit e058a31

Browse files
committed
address review comments
1 parent 667131b commit e058a31

File tree

2 files changed

+16
-15
lines changed

2 files changed

+16
-15
lines changed

packages/module/src/ColumnManagementModal/ColumnManagementModal.tsx

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -75,16 +75,7 @@ const ColumnManagementModal: FunctionComponent<ColumnManagementModalProps> = (
7575
setCurrentColumns(currentColumns.map(column => ({ ...column, isShown: column.isShownByDefault ?? false })));
7676
};
7777

78-
const handleSelect = (item: ListManagerItem) => {
79-
const newColumns = currentColumns.map(column =>
80-
column.key === item.key
81-
? { ...column, isShown: item.isSelected ?? column.isShownByDefault }
82-
: column
83-
);
84-
setCurrentColumns(newColumns);
85-
};
86-
87-
const handleSelectAll = (items: ListManagerItem[]) => {
78+
const updateColumns = (items: ListManagerItem[]) => {
8879
const newColumns = currentColumns.map(column => {
8980
const matchingItem = items.find(item => item.key === column.key);
9081
return matchingItem
@@ -94,6 +85,14 @@ const ColumnManagementModal: FunctionComponent<ColumnManagementModalProps> = (
9485
setCurrentColumns(newColumns);
9586
};
9687

88+
const handleSelect = (item: ListManagerItem) => {
89+
updateColumns([item]);
90+
};
91+
92+
const handleSelectAll = (items: ListManagerItem[]) => {
93+
updateColumns(items);
94+
};
95+
9796
const handleOrderChange = (items: ListManagerItem[]) => {
9897
// Update the order of currentColumns based on the new order from ListManager
9998
const newColumns = items.map(item => {

packages/module/src/ListManager/ListManager.tsx

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ export interface ListManagerProps {
4646
onCancel?: () => void;
4747
/** Enable drag and drop functionality for reordering items */
4848
enableDragDrop?: boolean;
49+
/** Custom aria-label for the DataList */
50+
dataListAriaLabel?: string;
4951
}
5052

5153
const ListManager: FunctionComponent<ListManagerProps> = (
@@ -56,7 +58,8 @@ const ListManager: FunctionComponent<ListManagerProps> = (
5658
onOrderChange,
5759
onSave,
5860
onCancel,
59-
enableDragDrop = true }: ListManagerProps) => {
61+
enableDragDrop = true,
62+
dataListAriaLabel = 'Selected columns' }: ListManagerProps) => {
6063

6164
const [ currentColumns, setCurrentColumns ] = useState(
6265
() => columns.map(column => ({ ...column, isSelected: column.isSelected ?? column.isShownByDefault, id: column.key }))
@@ -115,14 +118,13 @@ const ListManager: FunctionComponent<ListManagerProps> = (
115118
isChecked={column.isSelected}
116119
onChange={() => handleChange(column.key)}
117120
isDisabled={column.isUntoggleable}
118-
aria-labelledby={`${ouiaId}-column-${index}-label`}
119121
ouiaId={`${ouiaId}-column-${index}-checkbox`}
120122
id={`${ouiaId}-column-${index}-checkbox`}
121123
/>
122124
<DataListItemCells
123125
dataListCells={[
124126
<DataListCell key={column.key} data-ouia-component-id={`${ouiaId}-column-${index}-label`}>
125-
<label htmlFor={`${ouiaId}-column-${index}-checkbox`} id={`${ouiaId}-column-${index}-label`}>
127+
<label htmlFor={`${ouiaId}-column-${index}-checkbox`}>
126128
{column.title}
127129
</label>
128130
</DataListCell>
@@ -158,11 +160,11 @@ const ListManager: FunctionComponent<ListManagerProps> = (
158160
// eslint-disable-next-line no-console
159161
({ id: column.key, content: column.title })
160162
)}
161-
wrapper={<DataList aria-label="Selected columns" isCompact data-ouia-component-id={`${ouiaId}-column-list`}/>}
163+
wrapper={<DataList aria-label={dataListAriaLabel} isCompact data-ouia-component-id={`${ouiaId}-column-list`}/>}
162164
/>
163165
</DragDropSort>
164166
) : (
165-
<DataList aria-label="Selected columns" isCompact data-ouia-component-id={`${ouiaId}-column-list`}>
167+
<DataList aria-label={dataListAriaLabel} isCompact data-ouia-component-id={`${ouiaId}-column-list`}>
166168
{currentColumns.map((column, index) => (
167169
<DataListItem key={column.key}>
168170
{renderDataListItem(column, index)}

0 commit comments

Comments
 (0)