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, 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 = () => { toggleEdit = () => {
const editing = !this.state.editing; const editing = !this.state.editing;
this.setState({ 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 = () => { save = () => {
const { record, handleSave } = this.props; const { record, handleSave } = this.props;
this.form.validateFields((error, values) => { this.form.validateFields((error, values) => {
@ -103,6 +84,7 @@ class EditableCell extends React.Component {
<Input <Input
ref={node => (this.input = node)} ref={node => (this.input = node)}
onPressEnter={this.save} onPressEnter={this.save}
onBlur={this.save}
/> />
)} )}
</FormItem> </FormItem>