Skip to content

Commit

Permalink
Use withSafeTimeout HOC for setTimeout
Browse files Browse the repository at this point in the history
  • Loading branch information
jayshenk committed May 15, 2018
1 parent f4a4358 commit 7d6e6a1
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion editor/components/rich-text/inline-blocks.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
*/
import { Component, Fragment, compose } from '@wordpress/element';
import { withSelect, withDispatch } from '@wordpress/data';
import { withSafeTimeout } from '@wordpress/components';

/**
* Internal dependencies
Expand All @@ -22,10 +23,12 @@ class InlineBlocks extends Component {
}

componentDidMount() {
const { setTimeout, setInsertAvailable } = this.props;

// When moving between two different RichText with the keyboard, we need to
// make sure `setInsertAvailable` is called after `setInsertUnavailable`
// from previous RichText so that editor state is correct
setTimeout( this.props.setInsertAvailable );
setTimeout( setInsertAvailable );
}

componentDidUpdate( prevProps ) {
Expand Down Expand Up @@ -132,4 +135,5 @@ export default compose( [
completeInsert: completeInlineInsert,
};
} ),
withSafeTimeout,
] )( InlineBlocks );

0 comments on commit 7d6e6a1

Please sign in to comment.