Skip to content

Commit

Permalink
RichText: Throttle changes for performance reasons
Browse files Browse the repository at this point in the history
  • Loading branch information
youknowriad committed Feb 9, 2018
1 parent 84132f8 commit b357ef0
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion blocks/rich-text/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {
find,
defer,
noop,
throttle,
} from 'lodash';
import { nodeListToReact } from 'dom-react';
import 'element-closest';
Expand Down Expand Up @@ -92,6 +93,7 @@ export default class RichText extends Component {
this.getSettings = this.getSettings.bind( this );
this.onSetup = this.onSetup.bind( this );
this.onChange = this.onChange.bind( this );
this.throttledOnChange = throttle( this.onChange.bind( this ), 500 );
this.onNewBlock = this.onNewBlock.bind( this );
this.onNodeChange = this.onNodeChange.bind( this );
this.onKeyDown = this.onKeyDown.bind( this );
Expand Down Expand Up @@ -149,7 +151,7 @@ export default class RichText extends Component {
editor.on( 'BeforeExecCommand', this.maybePropagateUndo );
editor.on( 'PastePreProcess', this.onPastePreProcess, true /* Add before core handlers */ );
editor.on( 'paste', this.onPaste, true /* Add before core handlers */ );
editor.on( 'input', this.onChange );
editor.on( 'input', this.throttledOnChange );

patterns.apply( this, [ editor ] );

Expand Down

0 comments on commit b357ef0

Please sign in to comment.