From 3afe22a02c2a394adfe0fc06487c944c10684357 Mon Sep 17 00:00:00 2001 From: Mac Date: Thu, 1 Mar 2018 17:22:07 -0800 Subject: [PATCH 1/2] Allow edits to be rejected for EditableCell Currently, if I don't change the controlled value as the result of a `onConfirm`, this check prevents the original value from overriding the savedValue. This is useful in a case where input to the `EditableCell` is being validated, and if it doesn't pass validation, the value of the cell shouldn't change. --- packages/table/src/cell/editableCell.tsx | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/packages/table/src/cell/editableCell.tsx b/packages/table/src/cell/editableCell.tsx index a27ac16f63..f4b5be4b59 100644 --- a/packages/table/src/cell/editableCell.tsx +++ b/packages/table/src/cell/editableCell.tsx @@ -96,9 +96,7 @@ export class EditableCell extends React.Component Date: Thu, 1 Mar 2018 17:37:31 -0800 Subject: [PATCH 2/2] Update test --- packages/table/test/editableCellTests.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/table/test/editableCellTests.tsx b/packages/table/test/editableCellTests.tsx index 1ee473301a..d00a09dd9b 100644 --- a/packages/table/test/editableCellTests.tsx +++ b/packages/table/test/editableCellTests.tsx @@ -62,7 +62,7 @@ describe("", () => { expect(onConfirm.called).to.be.true; }); - it("doesn't change edited value on non-value prop changes", () => { + it("does change edited value on non-value prop changes", () => { const onCancel = sinon.spy(); const onChange = sinon.spy(); const onConfirm = sinon.spy(); @@ -87,7 +87,7 @@ describe("", () => { elem.setProps({ onChange: null }); // value stays the same - expect(elem.find(`.${Classes.TABLE_EDITABLE_TEXT} .pt-editable-content`).text()).to.equal("new-text"); + expect(elem.find(`.${Classes.TABLE_EDITABLE_TEXT} .pt-editable-content`).text()).to.equal("test-value-5000"); // confirm input.simulate("blur");