mirror of
https://github.com/ant-design/ant-design.git
synced 2025-01-21 00:14:44 +08:00
commit
8f7d4970a5
@ -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>
|
||||||
|
Loading…
Reference in New Issue
Block a user