update table demo

This commit is contained in:
liuchuzhang 2019-02-21 20:23:00 +08:00
parent 440408a1dd
commit dfa6080d39

View File

@ -34,18 +34,6 @@ class EditableCell extends React.Component {
editing: false,
}
componentDidMount() {
if (this.props.editable) {
document.addEventListener('click', this.handleClickOutside, true);
}
}
componentWillUnmount() {
if (this.props.editable) {
document.removeEventListener('click', this.handleClickOutside, true);
}
}
toggleEdit = () => {
const editing = !this.state.editing;
this.setState({ editing }, () => {
@ -55,13 +43,6 @@ class EditableCell extends React.Component {
});
}
handleClickOutside = (e) => {
const { editing } = this.state;
if (editing && this.cell !== e.target && !this.cell.contains(e.target)) {
this.save();
}
}
save = () => {
const { record, handleSave } = this.props;
this.form.validateFields((error, values) => {
@ -103,6 +84,7 @@ class EditableCell extends React.Component {
<Input
ref={node => (this.input = node)}
onPressEnter={this.save}
onBlur={this.save}
/>
)}
</FormItem>