Skip to content

Commit 1e826cc

Browse files
committed
handle array for filter.$select
1 parent 1aa54c2 commit 1e826cc

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

src/components/CippTable/CIPPTableToptoolbar.js

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,12 @@ export const CIPPTableToptoolbar = ({
176176
queryKey: `${queryKey ? queryKey : title}-${filterName}`,
177177
});
178178
if (filter?.$select) {
179-
const selectedColumns = filter.$select.split(",");
179+
let selectedColumns = [];
180+
if (Array.isArray(filter?.$select)) {
181+
selectedColumns = filter?.$select;
182+
} else {
183+
selectedColumns = filter?.$select.split(",");
184+
}
180185
const setNestedVisibility = (col) => {
181186
if (typeof col === "object" && col !== null) {
182187
Object.keys(col).forEach((key) => {
@@ -191,10 +196,12 @@ export const CIPPTableToptoolbar = ({
191196
}
192197
}
193198
};
194-
setConfiguredSimpleColumns(selectedColumns);
195-
selectedColumns.forEach((col) => {
196-
setNestedVisibility(col);
197-
});
199+
if (selectedColumns.length > 0) {
200+
setConfiguredSimpleColumns(selectedColumns);
201+
selectedColumns.forEach((col) => {
202+
setNestedVisibility(col);
203+
});
204+
}
198205
}
199206
}
200207
};

0 commit comments

Comments
 (0)