diff --git a/src/components/DatatableV2/buttons/ExpandAllButton.tsx b/src/components/DatatableV2/buttons/ExpandAllButton.tsx index 6780c8200..405e1a379 100644 --- a/src/components/DatatableV2/buttons/ExpandAllButton.tsx +++ b/src/components/DatatableV2/buttons/ExpandAllButton.tsx @@ -3,16 +3,18 @@ import IconButton from '../../ButtonV2/IconButton'; import { useSafeTranslation } from '../../../hooks/useSafeTranslation'; const ExpandAllButton = ({ table }: { table: DatatableInstance }) => { + const { t } = useSafeTranslation(); const { getIsSomeRowsExpanded, getState, - options: { renderDetailPanel }, + options: { renderDetailPanel, enableExpandAll }, toggleAllRowsExpanded, } = table; const { isLoading } = getState(); const areSomeRowsExpanded = getIsSomeRowsExpanded(); - const { t } = useSafeTranslation(); + + if (!enableExpandAll) return null; return ( ({ table: DatatableInstance; row: DatatableRow; }) => { + const { t } = useSafeTranslation(); const { options: { renderDetailPanel }, } = table; @@ -16,7 +17,6 @@ const ExpandButton = ({ const canExpand = getCanExpand(); const isExpanded = getIsExpanded(); - const { t } = useSafeTranslation(); return ( ({ )} - ) : Object.values(displayColumnIds).indexOf(columnDef.id) > 0 ? ( + ) : Object.values(displayColumnIds).includes(columnDef.id) ? ( {headerElement} diff --git a/src/components/DatatableV2/hooks/useDisplayColumns.tsx b/src/components/DatatableV2/hooks/useDisplayColumns.tsx index ea3d887f9..d58a32b4e 100644 --- a/src/components/DatatableV2/hooks/useDisplayColumns.tsx +++ b/src/components/DatatableV2/hooks/useDisplayColumns.tsx @@ -21,10 +21,8 @@ export const useDisplayColumns = ( tableOptions.enableExpanding && { id: displayColumnIds.expand, header: '', - headerComponent: tableOptions.enableExpandAll - ? ExpandAllButton - : null, - cell: ExpandButton, + headerComponent: (props) => , + cell: (props) => , size: 56, ...tableOptions.defaultDisplayColumn, }, @@ -59,7 +57,6 @@ export const useDisplayColumns = ( ).filter(Boolean), [ tableOptions.enableExpanding, - tableOptions.enableExpandAll, tableOptions.enableRowSelection, tableOptions.enableSelectAll, tableOptions.enableMultiRowSelection,