Skip to content

Commit

Permalink
release v1.1.1 - fix edit cancel bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
KevinVandy committed Aug 13, 2023
1 parent 814819f commit 531bd68
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 20 deletions.
7 changes: 6 additions & 1 deletion apps/mantine-react-table-docs/pages/changelog.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,15 @@ import Head from 'next/head';

### V1

#### V1.1.1 - 2023-08-12

- Fixed editing cancel button not restoring original row data in modal editDisplayMode

#### V1.1.0 - 2023-08-12

- Fixed editing cancel button not restoring original row data
- Fixed editing cancel button not restoring original row data in inline row editDisplayMode
- Fixed Filter Range Slider initial range min and max sometimes not being set correctly after loading data
- Removed Edit Modal Title by default
- Replaced `"Unsorted"` tooltip on header sort icon buttons with sort by next sort direction tooltip
- Added ar translations that can be imported from `'material-react-table/locales/ar'`

Expand Down
2 changes: 1 addition & 1 deletion packages/mantine-react-table/package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "1.1.0",
"version": "1.1.1",
"license": "MIT",
"name": "mantine-react-table",
"description": "A fully featured Mantine implementation of TanStack React Table V8, written from the ground up in TypeScript.",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export const MRT_EditActionButtons = <TData extends Record<string, any> = {}>({
onEditingRowCancel?.({ row, table });
setEditingRow(null);
}
row._valuesCache = row.original;
row._valuesCache = {} as any; //reset values cache
};

const handleSubmitRow = () => {
Expand Down
8 changes: 5 additions & 3 deletions packages/mantine-react-table/src/column.utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -436,9 +436,11 @@ export const createRow = <TData extends Record<string, any> = {}>(
originalRow ??
Object.assign(
{},
...getAllLeafColumnDefs(table.options.columns).map((col) => ({
[getColumnId(col)]: '',
})),
...getAllLeafColumnDefs(table.options.columns)
.filter((c) => c.columnDefType === 'data')
.map((col) => ({
[getColumnId(col)]: '',
})),
),
-1,
0,
Expand Down
11 changes: 9 additions & 2 deletions packages/mantine-react-table/src/hooks/useMRT_Effects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,14 @@ export const useMRT_Effects = <TData extends Record<string, any> = {}>(
getState,
options: { enablePagination, rowCount },
} = table;
const { globalFilter, isFullScreen, pagination, sorting } = getState();
const {
globalFilter,
isFullScreen,
pagination,
sorting,
isLoading,
showSkeletons,
} = getState();

const isMounted = useRef(false);
const initialBodyHeight = useRef<string>();
Expand Down Expand Up @@ -41,7 +48,7 @@ export const useMRT_Effects = <TData extends Record<string, any> = {}>(

//if page index is out of bounds, set it to the last page
useEffect(() => {
if (!enablePagination) return;
if (!enablePagination || isLoading || showSkeletons) return;
const { pageIndex, pageSize } = pagination;
const totalRowCount =
rowCount ?? table.getPrePaginationRowModel().rows.length;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,9 @@ export const MRT_EditCellTextInput = <TData extends Record<string, any> = {}>({
//@ts-ignore
row._valuesCache[column.id] = newValue;
if (isCreating) {
setCreatingRow({ ...row });
setCreatingRow(row);
} else if (isEditing) {
setEditingRow({ ...row });
setEditingRow(row);
}
};

Expand Down
23 changes: 13 additions & 10 deletions packages/mantine-react-table/src/modals/MRT_EditRowModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,21 +50,24 @@ export const MRT_EditRowModal = <TData extends Record<string, any> = {}>({
<MRT_EditCellTextInput cell={cell} key={cell.id} table={table} />
));

const handleCancel = () => {
if (creatingRow) {
onCreatingRowCancel?.({ row, table });
setCreatingRow(null);
} else {
onEditingRowCancel?.({ row, table });
setEditingRow(null);
}
row._valuesCache = {} as any; //reset values cache
modalProps.onClose?.();
};

return (
<Modal
closeOnClickOutside={false}
onClose={() => {
if (creatingRow) {
onCreatingRowCancel?.({ row, table });
setCreatingRow(null);
} else {
onEditingRowCancel?.({ row, table });
setEditingRow(null);
}
}}
opened={open}
withCloseButton={false}
{...modalProps}
onClose={handleCancel}
key={row.id}
>
{((creatingRow &&
Expand Down

2 comments on commit 531bd68

@vercel
Copy link

@vercel vercel bot commented on 531bd68 Aug 13, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vercel
Copy link

@vercel vercel bot commented on 531bd68 Aug 13, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.