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

Allow edits to be rejected for EditableCell #2192

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions packages/table/src/cell/editableCell.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,7 @@ export class EditableCell extends React.Component<IEditableCellProps, IEditableC

public componentWillReceiveProps(nextProps: IEditableCellProps) {
const { value } = nextProps;
if (value !== this.props.value) {
Copy link
Contributor

Choose a reason for hiding this comment

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

@maclockard i believe removing this check is wrong. it should instead by != null, just like EditableText does it. i'm going to close this PR and open my own with the correct change, and a refactor to the corresponding test.

thanks for suggesting this feature!

this.setState({ savedValue: value, dirtyValue: value });
}
this.setState({ savedValue: value, dirtyValue: value });
}

public render() {
Expand Down
4 changes: 2 additions & 2 deletions packages/table/test/editableCellTests.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ describe("<EditableCell>", () => {
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();
Expand All @@ -87,7 +87,7 @@ describe("<EditableCell>", () => {
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");
Expand Down