From 6d3c7466a43bb431b07ce7351e92106fb086265d Mon Sep 17 00:00:00 2001 From: dleadbetter <> Date: Mon, 13 May 2024 11:28:25 -0400 Subject: [PATCH] CDC #157 - Adjusting DataTableColumnSelector to not add columns no longer included in props --- .../src/components/DataTableColumnSelector.js | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/packages/semantic-ui/src/components/DataTableColumnSelector.js b/packages/semantic-ui/src/components/DataTableColumnSelector.js index 6e82ffbd..5f4f4c0a 100644 --- a/packages/semantic-ui/src/components/DataTableColumnSelector.js +++ b/packages/semantic-ui/src/components/DataTableColumnSelector.js @@ -112,11 +112,15 @@ const useColumnSelector = (WrappedComponent: ComponentType) => ( }; } - // Iterate over the session columns to preserve the ordering - const columns = _.map(session.columns, (column) => ({ - ...(_.findWhere(props.columns, { name: column.name }) || {}), - ...column - })); + const columns = []; + + // Iterate over the session columns to preserve the ordering. + _.each(session.columns, (column) => { + const findColumn = _.findWhere(props.columns, { name: column.name }); + if (findColumn) { + columns.push({ ...findColumn, ...column }); + } + }); // Append any new columns not stored in the session const columnNames = _.pluck(columns, 'name');