Skip to content

Commit eae455f

Browse files
committed
discardOnRowChange -> closeOnExternalRowChange
1 parent 9f0b5a0 commit eae455f

4 files changed

Lines changed: 10 additions & 7 deletions

File tree

src/DataGrid.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -904,7 +904,7 @@ export function DataGrid<R, SR = unknown, K extends Key = Key>(props: DataGridPr
904904
const { idx, row } = selectedPosition;
905905
const column = columns[idx];
906906
const colSpan = getColSpan(column, lastFrozenColumnIndex, { type: 'ROW', row });
907-
const discardOnRowChange = column.editorOptions?.discardOnRowChange !== false;
907+
const closeOnExternalRowChange = column.editorOptions?.closeOnExternalRowChange ?? true;
908908

909909
const closeEditor = (shouldFocusCell: boolean) => {
910910
setShouldFocusCell(shouldFocusCell);
@@ -926,7 +926,10 @@ export function DataGrid<R, SR = unknown, K extends Key = Key>(props: DataGridPr
926926
}
927927
};
928928

929-
if (discardOnRowChange && rows[selectedPosition.rowIdx] !== selectedPosition.originalRow) {
929+
if (
930+
closeOnExternalRowChange &&
931+
rows[selectedPosition.rowIdx] !== selectedPosition.originalRow
932+
) {
930933
// Discard changes if rows are updated from outside
931934
closeEditor(false);
932935
}

src/EditCell.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ export default function EditCell<R, SR>({
5757
navigate
5858
}: EditCellProps<R, SR>) {
5959
const frameRequestRef = useRef<number>(undefined);
60-
const commitOnOutsideClick = column.editorOptions?.commitOnOutsideClick !== false;
60+
const commitOnOutsideClick = column.editorOptions?.commitOnOutsideClick ?? true;
6161

6262
// We need to prevent the `useEffect` from cleaning up between re-renders,
6363
// as `onWindowCaptureMouseDown` might otherwise miss valid mousedown events.

src/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ export interface Column<TRow, TSummaryRow = unknown> {
6464
/** @default true */
6565
readonly commitOnOutsideClick?: Maybe<boolean>;
6666
/** @default true */
67-
readonly discardOnRowChange?: Maybe<boolean>;
67+
readonly closeOnExternalRowChange?: Maybe<boolean>;
6868
}>;
6969
}
7070

test/browser/column/renderEditCell.test.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ describe('Editor', () => {
218218
expect(getCellsAtRowIndex(0)[1]).toHaveTextContent(/^a1bac$/);
219219
});
220220

221-
it('should discard when discardOnRowChange is true or undefined and row is changed from outside', async () => {
221+
it('should discard when closeOnExternalRowChange is true or undefined and row is changed from outside', async () => {
222222
page.render(
223223
<EditorTest
224224
editorOptions={{
@@ -234,12 +234,12 @@ describe('Editor', () => {
234234
await expect.element(editor).not.toBeInTheDocument();
235235
});
236236

237-
it('should not discard when discardOnRowChange is false and row is changed from outside', async () => {
237+
it('should not discard when closeOnExternalRowChange is false and row is changed from outside', async () => {
238238
page.render(
239239
<EditorTest
240240
editorOptions={{
241241
commitOnOutsideClick: false,
242-
discardOnRowChange: false
242+
closeOnExternalRowChange: false
243243
}}
244244
/>
245245
);

0 commit comments

Comments
 (0)