diff --git a/src/components/Table/hoc/withTableSettings/withTableSettings.tsx b/src/components/Table/hoc/withTableSettings/withTableSettings.tsx index f469c59c0d..9c275e1a0a 100644 --- a/src/components/Table/hoc/withTableSettings/withTableSettings.tsx +++ b/src/components/Table/hoc/withTableSettings/withTableSettings.tsx @@ -66,30 +66,30 @@ export function getColumnStringTitle(column: TableColumnConfig) { return column.id; } +const getTableColumnSetupItem = ( + id: string, + isSelected: boolean | undefined, + column: TableColumnConfig | undefined, +): TableColumnSetupItem => { + const isProtected = Boolean(column?.meta?.selectedAlways); + + return { + id, + isSelected: isProtected ? true : isSelected, + isRequired: isProtected, + title: column ? getColumnStringTitle(column) : id, + }; +}; + export function getActualItems( columns: TableColumnConfig[], settings: TableSettingsData, ): TableColumnSetupItem[] { - const getTableColumnSetupItem = ( - id: string, - isSelected: boolean | undefined, - column = columns.find((column) => column.id === id), - ): TableColumnSetupItem => { - const isProtected = Boolean(column?.meta?.selectedAlways); - - return { - id, - isSelected: isProtected ? true : isSelected, - isRequired: isProtected, - title: column ? getColumnStringTitle(column) : id, - }; - }; - const sortableItems: TableColumnSetupItem[] = []; settings.forEach(({id, isSelected}) => { if (columns.some((column) => id === column.id)) { - sortableItems.push(getTableColumnSetupItem(id, isSelected)); + sortableItems.push(getTableColumnSetupItem(id, isSelected, undefined)); } });