Skip to content

Commit

Permalink
[form-builder] Fix bug where annotations containing references didn't…
Browse files Browse the repository at this point in the history
… clean up properly (#542)
  • Loading branch information
skogsmaskin authored and bjoerge committed Jan 30, 2018
1 parent d52b31c commit 9fc8d6f
Showing 1 changed file with 9 additions and 7 deletions.
Expand Up @@ -94,14 +94,11 @@ export default class FormBuilderSpan extends React.Component {
}

handleCloseInput = () => {
// Let it happen after focus is set in the editor (state may be out of sync)
this.props.editor.focus()
setTimeout(() => {
if (this.state.isEditing) {
this.setState({isEditing: false, focusedAnnotationName: undefined})
}
this.garbageCollect()
}, 100)
if (this.state.isEditing) {
this.setState({isEditing: false, focusedAnnotationName: undefined})
}
this.garbageCollect()
}

garbageCollect() {
Expand Down Expand Up @@ -183,6 +180,11 @@ export default class FormBuilderSpan extends React.Component {
...annotations,
[name]: applyAll(annotations[name], event.patches)
}
Object.keys(nextAnnotations).forEach(key => {
if (nextAnnotations[key] === undefined) {
delete nextAnnotations[key]
}
})
const {node, editor} = this.props
const data = {
...node.data.toObject(),
Expand Down

0 comments on commit 9fc8d6f

Please sign in to comment.