mirror of
https://github.com/ant-design/ant-design.git
synced 2024-11-28 13:09:40 +08:00
update table demo
This commit is contained in:
parent
440408a1dd
commit
dfa6080d39
@ -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>
|
||||
|
Loading…
Reference in New Issue
Block a user