Skip to content

Commit a7d73a1

Browse files
committed
Fix <DataTable> does not allow to put a button in the column's header
1 parent a06587e commit a7d73a1

File tree

2 files changed

+20
-7
lines changed

2 files changed

+20
-7
lines changed

packages/ra-ui-materialui/src/list/datatable/DataTable.stories.tsx

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ import {
3737
import {
3838
BulkDeleteButton,
3939
BulkExportButton,
40+
CreateButton,
4041
EditButton,
4142
SelectAllButton as RaSelectAllButton,
4243
} from '../../button';
@@ -896,3 +897,17 @@ export const NonPrimitiveData = () => (
896897
</DataTable>
897898
</Wrapper>
898899
);
900+
901+
export const HeaderButton = () => (
902+
<Wrapper i18nProvider={polyglotI18nProvider(() => defaultMessages, 'en')}>
903+
<DataTable>
904+
<DataTable.Col source="id" />
905+
<DataTable.Col source="title" />
906+
<DataTable.Col label="Author" source="author.name" disableSort />
907+
<DataTable.Col source="year" />
908+
<DataTable.Col label={<CreateButton />}>
909+
<EditButton />
910+
</DataTable.Col>
911+
</DataTable>
912+
</Wrapper>
913+
);

packages/ra-ui-materialui/src/list/datatable/DataTableHeadCell.tsx

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -120,13 +120,11 @@ export const DataTableHeadCell = React.memo(
120120
</TableSortLabel>
121121
</Tooltip>
122122
) : (
123-
<TableSortLabel disabled>
124-
<FieldTitle
125-
label={label}
126-
source={source}
127-
resource={resource}
128-
/>
129-
</TableSortLabel>
123+
<FieldTitle
124+
label={label}
125+
source={source}
126+
resource={resource}
127+
/>
130128
)}
131129
</TableCellStyled>
132130
);

0 commit comments

Comments
 (0)