Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DataGrid] Remove disableIgnoreModificationsIfProcessingProps prop #6640

Merged
merged 2 commits into from
Oct 31, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 0 additions & 11 deletions docs/data/data-grid/editing/editing.md
Original file line number Diff line number Diff line change
Expand Up @@ -237,17 +237,6 @@ While the promise is not resolved, the edit component will receive an `isProcess

{{"demo": "ValidateServerNameGrid.js", "bg": "inline", "defaultCodeOpen": false}}

:::warning
If the user performs an action that saves the changes and exits the edit mode (e.g. pressing <kbd class="key">Enter</kbd>) while the props are still being processed, the changes will be discarded upon exit.
To avoid this, use the `disableIgnoreModificationsIfProcessingProps` prop to keep the cell or row in edit mode while props are processed:

```tsx
<DataGrid disableIgnoreModificationsIfProcessingProps />
```

In v6, this prop will be removed and the editing API will behave, by default, like if it was enabled.
:::

## Persistence

The `processRowUpdate` prop is called when the user performs an action to [stop editing](#stop-editing).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@ Below are described the steps you need to make to migrate from v5 to v6.

- The `selectionChange` event was renamed to `rowSelectionChange`.

### Removed props

- The `disableIgnoreModificationsIfProcessingProps` prop was removed and its behavior when `true` was incorporated as the default behavior.
The old behavior can be restored by using `apiRef.current.stopRowEditMode({ ignoreModifications: true })` or `apiRef.current.stopCellEditMode({ ignoreModifications: true })`.

<!--
### CSS classes

Expand All @@ -47,10 +52,6 @@ TBD

TBD

### Removed props

TBD

### `apiRef` methods

TBD
Expand Down
1 change: 0 additions & 1 deletion docs/pages/x/api/data-grid/data-grid-premium.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@
"disableColumnSelector": { "type": { "name": "bool" } },
"disableDensitySelector": { "type": { "name": "bool" } },
"disableExtendRowFullWidth": { "type": { "name": "bool" } },
"disableIgnoreModificationsIfProcessingProps": { "type": { "name": "bool" } },
"disableMultipleColumnsFiltering": { "type": { "name": "bool" } },
"disableMultipleColumnsSorting": { "type": { "name": "bool" } },
"disableMultipleRowSelection": { "type": { "name": "bool" } },
Expand Down
1 change: 0 additions & 1 deletion docs/pages/x/api/data-grid/data-grid-pro.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@
"disableColumnSelector": { "type": { "name": "bool" } },
"disableDensitySelector": { "type": { "name": "bool" } },
"disableExtendRowFullWidth": { "type": { "name": "bool" } },
"disableIgnoreModificationsIfProcessingProps": { "type": { "name": "bool" } },
"disableMultipleColumnsFiltering": { "type": { "name": "bool" } },
"disableMultipleColumnsSorting": { "type": { "name": "bool" } },
"disableMultipleRowSelection": { "type": { "name": "bool" } },
Expand Down
1 change: 0 additions & 1 deletion docs/pages/x/api/data-grid/data-grid.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
"disableColumnSelector": { "type": { "name": "bool" } },
"disableDensitySelector": { "type": { "name": "bool" } },
"disableExtendRowFullWidth": { "type": { "name": "bool" } },
"disableIgnoreModificationsIfProcessingProps": { "type": { "name": "bool" } },
"disableRowSelectionOnClick": { "type": { "name": "bool" } },
"disableVirtualization": { "type": { "name": "bool" } },
"editMode": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
"disableColumnSelector": "If <code>true</code>, hiding/showing columns is disabled.",
"disableDensitySelector": "If <code>true</code>, the density selector is disabled.",
"disableExtendRowFullWidth": "If <code>true</code>, rows will not be extended to fill the full width of the grid container.",
"disableIgnoreModificationsIfProcessingProps": "If <code>true</code>, modification to a cell will not be discarded if the mode is changed from &quot;edit&quot; to &quot;view&quot; while processing props.",
"disableMultipleColumnsFiltering": "If <code>true</code>, filtering with multiple columns is disabled.",
"disableMultipleColumnsSorting": "If <code>true</code>, sorting with multiple columns is disabled.",
"disableMultipleRowSelection": "If <code>true</code>, multiple selection using the Ctrl or CMD key is disabled.",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
"disableColumnSelector": "If <code>true</code>, hiding/showing columns is disabled.",
"disableDensitySelector": "If <code>true</code>, the density selector is disabled.",
"disableExtendRowFullWidth": "If <code>true</code>, rows will not be extended to fill the full width of the grid container.",
"disableIgnoreModificationsIfProcessingProps": "If <code>true</code>, modification to a cell will not be discarded if the mode is changed from &quot;edit&quot; to &quot;view&quot; while processing props.",
"disableMultipleColumnsFiltering": "If <code>true</code>, filtering with multiple columns is disabled.",
"disableMultipleColumnsSorting": "If <code>true</code>, sorting with multiple columns is disabled.",
"disableMultipleRowSelection": "If <code>true</code>, multiple selection using the Ctrl or CMD key is disabled.",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
"disableColumnSelector": "If <code>true</code>, hiding/showing columns is disabled.",
"disableDensitySelector": "If <code>true</code>, the density selector is disabled.",
"disableExtendRowFullWidth": "If <code>true</code>, rows will not be extended to fill the full width of the grid container.",
"disableIgnoreModificationsIfProcessingProps": "If <code>true</code>, modification to a cell will not be discarded if the mode is changed from &quot;edit&quot; to &quot;view&quot; while processing props.",
"disableMultipleColumnsFiltering": "If <code>true</code>, filtering with multiple columns is disabled.",
"disableMultipleColumnsSorting": "If <code>true</code>, sorting with multiple columns is disabled.",
"disableMultipleRowSelection": "If <code>true</code>, multiple selection using the Ctrl or CMD key is disabled.",
Expand Down
1 change: 0 additions & 1 deletion docs/translations/api-docs/data-grid/data-grid-pro-pt.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
"disableColumnSelector": "If <code>true</code>, hiding/showing columns is disabled.",
"disableDensitySelector": "If <code>true</code>, the density selector is disabled.",
"disableExtendRowFullWidth": "If <code>true</code>, rows will not be extended to fill the full width of the grid container.",
"disableIgnoreModificationsIfProcessingProps": "If <code>true</code>, modification to a cell will not be discarded if the mode is changed from &quot;edit&quot; to &quot;view&quot; while processing props.",
"disableMultipleColumnsFiltering": "If <code>true</code>, filtering with multiple columns is disabled.",
"disableMultipleColumnsSorting": "If <code>true</code>, sorting with multiple columns is disabled.",
"disableMultipleRowSelection": "If <code>true</code>, multiple selection using the Ctrl or CMD key is disabled.",
Expand Down
1 change: 0 additions & 1 deletion docs/translations/api-docs/data-grid/data-grid-pro-zh.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
"disableColumnSelector": "If <code>true</code>, hiding/showing columns is disabled.",
"disableDensitySelector": "If <code>true</code>, the density selector is disabled.",
"disableExtendRowFullWidth": "If <code>true</code>, rows will not be extended to fill the full width of the grid container.",
"disableIgnoreModificationsIfProcessingProps": "If <code>true</code>, modification to a cell will not be discarded if the mode is changed from &quot;edit&quot; to &quot;view&quot; while processing props.",
"disableMultipleColumnsFiltering": "If <code>true</code>, filtering with multiple columns is disabled.",
"disableMultipleColumnsSorting": "If <code>true</code>, sorting with multiple columns is disabled.",
"disableMultipleRowSelection": "If <code>true</code>, multiple selection using the Ctrl or CMD key is disabled.",
Expand Down
1 change: 0 additions & 1 deletion docs/translations/api-docs/data-grid/data-grid-pro.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
"disableColumnSelector": "If <code>true</code>, hiding/showing columns is disabled.",
"disableDensitySelector": "If <code>true</code>, the density selector is disabled.",
"disableExtendRowFullWidth": "If <code>true</code>, rows will not be extended to fill the full width of the grid container.",
"disableIgnoreModificationsIfProcessingProps": "If <code>true</code>, modification to a cell will not be discarded if the mode is changed from &quot;edit&quot; to &quot;view&quot; while processing props.",
"disableMultipleColumnsFiltering": "If <code>true</code>, filtering with multiple columns is disabled.",
"disableMultipleColumnsSorting": "If <code>true</code>, sorting with multiple columns is disabled.",
"disableMultipleRowSelection": "If <code>true</code>, multiple selection using the Ctrl or CMD key is disabled.",
Expand Down
1 change: 0 additions & 1 deletion docs/translations/api-docs/data-grid/data-grid-pt.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
"disableColumnSelector": "If <code>true</code>, hiding/showing columns is disabled.",
"disableDensitySelector": "If <code>true</code>, the density selector is disabled.",
"disableExtendRowFullWidth": "If <code>true</code>, rows will not be extended to fill the full width of the grid container.",
"disableIgnoreModificationsIfProcessingProps": "If <code>true</code>, modification to a cell will not be discarded if the mode is changed from &quot;edit&quot; to &quot;view&quot; while processing props.",
"disableRowSelectionOnClick": "If <code>true</code>, the selection on click on a row or cell is disabled.",
"disableVirtualization": "If <code>true</code>, the virtualization is disabled.",
"editMode": "Controls whether to use the cell or row editing.",
Expand Down
1 change: 0 additions & 1 deletion docs/translations/api-docs/data-grid/data-grid-zh.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
"disableColumnSelector": "If <code>true</code>, hiding/showing columns is disabled.",
"disableDensitySelector": "If <code>true</code>, the density selector is disabled.",
"disableExtendRowFullWidth": "If <code>true</code>, rows will not be extended to fill the full width of the grid container.",
"disableIgnoreModificationsIfProcessingProps": "If <code>true</code>, modification to a cell will not be discarded if the mode is changed from &quot;edit&quot; to &quot;view&quot; while processing props.",
"disableRowSelectionOnClick": "If <code>true</code>, the selection on click on a row or cell is disabled.",
"disableVirtualization": "If <code>true</code>, the virtualization is disabled.",
"editMode": "Controls whether to use the cell or row editing.",
Expand Down
1 change: 0 additions & 1 deletion docs/translations/api-docs/data-grid/data-grid.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
"disableColumnSelector": "If <code>true</code>, hiding/showing columns is disabled.",
"disableDensitySelector": "If <code>true</code>, the density selector is disabled.",
"disableExtendRowFullWidth": "If <code>true</code>, rows will not be extended to fill the full width of the grid container.",
"disableIgnoreModificationsIfProcessingProps": "If <code>true</code>, modification to a cell will not be discarded if the mode is changed from &quot;edit&quot; to &quot;view&quot; while processing props.",
"disableRowSelectionOnClick": "If <code>true</code>, the selection on click on a row or cell is disabled.",
"disableVirtualization": "If <code>true</code>, the virtualization is disabled.",
"editMode": "Controls whether to use the cell or row editing.",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -233,11 +233,6 @@ DataGridPremiumRaw.propTypes = {
* @default false
*/
disableExtendRowFullWidth: PropTypes.bool,
/**
* If `true`, modification to a cell will not be discarded if the mode is changed from "edit" to "view" while processing props.
* @default false
*/
disableIgnoreModificationsIfProcessingProps: PropTypes.bool,
/**
* If `true`, filtering with multiple columns is disabled.
* @default false
Expand Down
5 changes: 0 additions & 5 deletions packages/grid/x-data-grid-pro/src/DataGridPro/DataGridPro.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -209,11 +209,6 @@ DataGridProRaw.propTypes = {
* @default false
*/
disableExtendRowFullWidth: PropTypes.bool,
/**
* If `true`, modification to a cell will not be discarded if the mode is changed from "edit" to "view" while processing props.
* @default false
*/
disableIgnoreModificationsIfProcessingProps: PropTypes.bool,
/**
* If `true`, filtering with multiple columns is disabled.
* @default false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -971,7 +971,7 @@ describe('<DataGridPro /> - Cell Editing', () => {
});
});

it('should call stopCellEditMode with ignoreModifications=true if the props are being processed', async () => {
it('should call stopCellEditMode with ignoreModifications=false if the props are being processed', async () => {
columnProps.preProcessEditCellProps = () => new Promise(() => {});
render(<TestCase />);
const spiedStopCellEditMode = spy(apiRef.current, 'stopCellEditMode');
Expand All @@ -985,22 +985,7 @@ describe('<DataGridPro /> - Cell Editing', () => {
);
fireEvent.click(getCell(1, 1));
expect(spiedStopCellEditMode.callCount).to.equal(1);
expect(spiedStopCellEditMode.lastCall.args[0].ignoreModifications).to.equal(true);
});

it('should call stopCellEditMode with ignoreModifications=false if the props are being processed and disableIgnoreModificationsIfProcessingProps is true', async () => {
columnProps.preProcessEditCellProps = ({ props }: GridPreProcessEditCellProps) =>
new Promise((resolve) => resolve(props));
render(<TestCase disableIgnoreModificationsIfProcessingProps />);
const spiedStopCellEditMode = spy(apiRef.current, 'stopCellEditMode');
fireEvent.doubleClick(getCell(0, 1));
await act(() =>
apiRef.current.setEditCellValue({ id: 0, field: 'currencyPair', value: 'USD GBP' }),
);
fireEvent.click(getCell(1, 1));
expect(spiedStopCellEditMode.callCount).to.equal(1);
expect(spiedStopCellEditMode.lastCall.args[0].ignoreModifications).to.equal(false);
await act(() => Promise.resolve());
});
});

Expand Down Expand Up @@ -1063,7 +1048,7 @@ describe('<DataGridPro /> - Cell Editing', () => {
});
});

it('should call stopCellEditMode with ignoreModifications=true if the props are being processed', async () => {
it('should call stopCellEditMode with ignoreModifications=false if the props are being processed', async () => {
columnProps.preProcessEditCellProps = () => new Promise(() => {});
render(<TestCase />);
const spiedStopCellEditMode = spy(apiRef.current, 'stopCellEditMode');
Expand All @@ -1079,7 +1064,7 @@ describe('<DataGridPro /> - Cell Editing', () => {
);
fireEvent.keyDown(cell, { key: 'Enter' });
expect(spiedStopCellEditMode.callCount).to.equal(1);
expect(spiedStopCellEditMode.lastCall.args[0].ignoreModifications).to.equal(true);
expect(spiedStopCellEditMode.lastCall.args[0].ignoreModifications).to.equal(false);
});
});

Expand Down Expand Up @@ -1112,7 +1097,7 @@ describe('<DataGridPro /> - Cell Editing', () => {
});
});

it('should call stopCellEditMode with ignoreModifications=true if the props are being processed', async () => {
it('should call stopCellEditMode with ignoreModifications=false if the props are being processed', async () => {
columnProps.preProcessEditCellProps = () => new Promise(() => {});
render(<TestCase />);
const spiedStopCellEditMode = spy(apiRef.current, 'stopCellEditMode');
Expand All @@ -1128,7 +1113,7 @@ describe('<DataGridPro /> - Cell Editing', () => {
);
fireEvent.keyDown(cell, { key: 'Tab' });
expect(spiedStopCellEditMode.callCount).to.equal(1);
expect(spiedStopCellEditMode.lastCall.args[0].ignoreModifications).to.equal(true);
expect(spiedStopCellEditMode.lastCall.args[0].ignoreModifications).to.equal(false);
});
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -967,7 +967,7 @@ describe('<DataGridPro /> - Row Editing', () => {
});
});

it('should call stopRowEditMode with ignoreModifications=true if the props are being processed', async () => {
it('should call stopRowEditMode with ignoreModifications=false if the props are being processed', async () => {
column1Props.preProcessEditCellProps = () => new Promise(() => {});
render(<TestCase />);
const spiedStopRowEditMode = spy(apiRef.current, 'stopRowEditMode');
Expand All @@ -978,22 +978,6 @@ describe('<DataGridPro /> - Row Editing', () => {
fireEvent.click(getCell(1, 1));
clock.runToLast();
expect(spiedStopRowEditMode.callCount).to.equal(1);
expect(spiedStopRowEditMode.lastCall.args[0].ignoreModifications).to.equal(true);
});

it('should call stopRowEditMode with ignoreModifications=false if the props are being processed and disableIgnoreModificationsIfProcessingProps is true', async () => {
column1Props.preProcessEditCellProps = ({ props }: GridPreProcessEditCellProps) =>
new Promise((resolve) => resolve(props));
render(<TestCase disableIgnoreModificationsIfProcessingProps />);
const spiedStopRowEditMode = spy(apiRef.current, 'stopRowEditMode');
fireEvent.doubleClick(getCell(0, 1));
await act(() =>
apiRef.current.setEditCellValue({ id: 0, field: 'currencyPair', value: 'USD GBP' }),
);
fireEvent.click(getCell(1, 1));
clock.runToLast();
await act(() => Promise.resolve());
expect(spiedStopRowEditMode.callCount).to.equal(1);
expect(spiedStopRowEditMode.lastCall.args[0].ignoreModifications).to.equal(false);
});
});
Expand Down Expand Up @@ -1057,7 +1041,7 @@ describe('<DataGridPro /> - Row Editing', () => {
});
});

it('should call stopRowEditMode with ignoreModifications=true if the props are being processed', async () => {
it('should call stopRowEditMode with ignoreModifications=false if the props are being processed', async () => {
column1Props.preProcessEditCellProps = () => new Promise(() => {});
render(<TestCase />);
const spiedStopRowEditMode = spy(apiRef.current, 'stopRowEditMode');
Expand All @@ -1069,7 +1053,7 @@ describe('<DataGridPro /> - Row Editing', () => {
});
fireEvent.keyDown(cell.querySelector('input'), { key: 'Enter' });
expect(spiedStopRowEditMode.callCount).to.equal(1);
expect(spiedStopRowEditMode.lastCall.args[0].ignoreModifications).to.equal(true);
expect(spiedStopRowEditMode.lastCall.args[0].ignoreModifications).to.equal(false);
});
});

Expand Down Expand Up @@ -1130,7 +1114,7 @@ describe('<DataGridPro /> - Row Editing', () => {
});
});

it('should call stopRowEditMode with ignoreModifications=true if the props are being processed', async () => {
it('should call stopRowEditMode with ignoreModifications=false if the props are being processed', async () => {
column1Props.preProcessEditCellProps = () => new Promise(() => {});
render(<TestCase />);
const spiedStopRowEditMode = spy(apiRef.current, 'stopRowEditMode');
Expand All @@ -1142,7 +1126,7 @@ describe('<DataGridPro /> - Row Editing', () => {
});
fireEvent.keyDown(cell.querySelector('input'), { key: 'Tab' });
expect(spiedStopRowEditMode.callCount).to.equal(1);
expect(spiedStopRowEditMode.lastCall.args[0].ignoreModifications).to.equal(true);
expect(spiedStopRowEditMode.lastCall.args[0].ignoreModifications).to.equal(false);
});

it('should keep focus on the first column when editing the first column of the first row of the 2nd page', () => {
Expand Down
5 changes: 0 additions & 5 deletions packages/grid/x-data-grid/src/DataGrid/DataGrid.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -159,11 +159,6 @@ DataGridRaw.propTypes = {
* @default false
*/
disableExtendRowFullWidth: PropTypes.bool,
/**
* If `true`, modification to a cell will not be discarded if the mode is changed from "edit" to "view" while processing props.
* @default false
*/
disableIgnoreModificationsIfProcessingProps: PropTypes.bool,
/**
* If `true`, the selection on click on a row or cell is disabled.
* @default false
Expand Down
1 change: 0 additions & 1 deletion packages/grid/x-data-grid/src/DataGrid/useDataGridProps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ export const DATA_GRID_PROPS_DEFAULT_VALUES: DataGridPropsWithDefaultValues = {
disableMultipleColumnsSorting: false,
disableRowSelectionOnClick: false,
disableVirtualization: false,
disableIgnoreModificationsIfProcessingProps: false,
editMode: GridEditModes.Cell,
filterMode: 'client',
headerHeight: 56,
Expand Down