Skip to content

Commit

Permalink
Merge pull request #3487 from WordPress/fix/3450-onChange-forced-erro…
Browse files Browse the repository at this point in the history
…neously

fix/3450: Events passed to onChange erroneously triggered shouldForce
  • Loading branch information
tiny-james authored Nov 15, 2017
2 parents ceb4e69 + b5568ae commit 74d8ab9
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 74d8ab9

Please sign in to comment.