Skip to content

Commit

Permalink
Add a debounce to improve performance on large blocks
Browse files Browse the repository at this point in the history
  • Loading branch information
Glen Davies committed Jun 28, 2020
1 parent 3e7e8f3 commit 2b6c1dd
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions packages/block-library/src/classic/edit.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
/**
* External dependencies
*/
import { debounce } from 'lodash';

/**
* WordPress dependencies
*/
Expand Down Expand Up @@ -116,7 +121,7 @@ export default class ClassicEdit extends Component {
bookmark = null;
} );

editor.on( 'Paste Change input Undo Redo', () => {
editor.on( 'Paste Change input Undo Redo', debounce( () => {
const value = editor.getContent();

if ( value !== editor._lastChange ) {
Expand All @@ -125,7 +130,7 @@ export default class ClassicEdit extends Component {
content: value,
} );
}
} );
}, 250 ) );

editor.on( 'keydown', ( event ) => {
if (
Expand Down

0 comments on commit 2b6c1dd

Please sign in to comment.