Skip to content

Commit

Permalink
fix: fixed the column resizing
Browse files Browse the repository at this point in the history
  • Loading branch information
jordankoschei-okta committed Jul 25, 2024
1 parent 84f3af3 commit 6ee0a40
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 12 deletions.
19 changes: 13 additions & 6 deletions packages/odyssey-react-mui/src/DataTable/DataTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -639,6 +639,16 @@ const DataTable = ({
[columnIds],
) as string[];

const shouldDisplayRowActions = useMemo(
() =>
(hasRowReordering === true && onReorderRows) ||
rowActionButtons ||
rowActionMenuItems
? true
: false,
[hasRowReordering, onReorderRows, rowActionButtons, rowActionMenuItems],
);

const dataTable = useMaterialReactTable({
columns: columns,
data: data,
Expand Down Expand Up @@ -706,12 +716,7 @@ const DataTable = ({
}),

// Row actions
enableRowActions:
(hasRowReordering === true && onReorderRows) ||
rowActionButtons ||
rowActionMenuItems
? true
: false,
enableRowActions: shouldDisplayRowActions,
positionActionsColumn:
"last" as MRT_TableOptions<DataTableRowData>["positionActionsColumn"],
renderRowActions: ({ row }) => renderRowActions({ row }),
Expand Down Expand Up @@ -746,6 +751,8 @@ const DataTable = ({
// Refs
muiTableProps: {
ref: tableContentRef,
className:
!shouldDisplayRowActions && hasColumnResizing ? "remove-last-row" : "",
},

muiTableContainerProps: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,21 @@ const TableContent = ({
[innerWidthStyle, emptyState],
);

const shouldDisplayRowActions = useMemo(
() =>
(hasRowReordering === true && onReorderRows) ||
tableOptions.rowActionButtons ||
tableOptions.rowActionMenuItems
? true
: false,
[
hasRowReordering,
onReorderRows,
tableOptions.rowActionButtons,
tableOptions.rowActionMenuItems,
],
);

const dataTable = useMaterialReactTable({
data: !isEmpty && !isNoResults ? data : [],
columns,
Expand All @@ -289,6 +304,10 @@ const TableContent = ({
>,
muiTableProps: {
ref: tableContentRef,
className:
!shouldDisplayRowActions && tableOptions.hasColumnResizing
? "remove-last-row"
: "",
},
muiTableContainerProps: {
ref: tableInnerContainerRef,
Expand All @@ -300,12 +319,7 @@ const TableContent = ({
defaultColumn: {
Cell: defaultCell,
},
enableRowActions:
(hasRowReordering === true && onReorderRows) ||
tableOptions.rowActionButtons ||
tableOptions.rowActionMenuItems
? true
: false,
enableRowActions: shouldDisplayRowActions,
renderRowActions: ({ row }) => renderRowActions({ row }),
enableRowOrdering: hasRowReordering && Boolean(onReorderRows),
enableRowDragging: hasRowReordering && Boolean(onReorderRows),
Expand Down
17 changes: 17 additions & 0 deletions packages/odyssey-react-mui/src/theme/components.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2621,6 +2621,23 @@ export const components = ({
width: odysseyTokens.Spacing2,
},

// TEST OF RESIZING
[`.remove-last-row .${tableHeadClasses.root} &:last-of-type, .remove-last-row .${tableBodyClasses.root} &:last-of-type`]:
{
display: "none",
},

[`.remove-last-row .${tableHeadClasses.root} &:nth-last-of-type(2), .remove-last-row .${tableBodyClasses.root} &:nth-last-of-type(2)`]:
{
borderTopRightRadius: odysseyTokens.Spacing2,
borderBottomRightRadius: odysseyTokens.Spacing2,
flexGrow: 1,

[`& .Mui-TableHeadCell-ResizeHandle-Wrapper`]: {
display: "none",
},
},

[`&::after`]: {
display: "none",
},
Expand Down

0 comments on commit 6ee0a40

Please sign in to comment.