Merge pull request #14986 from liuchuzhang/table-doc

update table demo
This commit is contained in:
Wei Zhu 2019-02-21 20:58:05 +08:00 committed by GitHub
commit 8f7d4970a5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

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>