Skip to content

Commit

Permalink
fix/3450: Events passed to onChange erroneously triggered shouldForce
Browse files Browse the repository at this point in the history
  • Loading branch information
tiny-james committed Nov 15, 2017
1 parent ceb4e69 commit b5568ae
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions blocks/editable/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -287,18 +287,20 @@ export default class Editable extends Component {
}
}

onChange( shouldForce ) {
// Note that due to efficiency, speed and low cost requirements isDirty may
// not reflect reality for a brief period immediately after a change.
if ( ! shouldForce && ! this.editor.isDirty() ) {
return;
}

fireChange() {
this.savedContent = this.getContent();
this.editor.save();
this.props.onChange( this.savedContent );
}

onChange() {
// Note that due to efficiency, speed and low cost requirements isDirty may
// not reflect reality for a brief period immediately after a change.
if ( this.editor.isDirty() ) {
this.fireChange();
}
}

getEditorSelectionRect() {
let range = this.editor.selection.getRng();

Expand Down Expand Up @@ -393,7 +395,7 @@ export default class Editable extends Component {
)
) {
const forward = event.keyCode === DELETE;
this.onChange( true );
this.fireChange();
this.props.onMerge( forward );
event.preventDefault();
event.stopImmediatePropagation();
Expand Down

0 comments on commit b5568ae

Please sign in to comment.