Skip to content

Commit

Permalink
RichText: Fall back to setTimeout if no requestIdleCallback (#17213)
Browse files Browse the repository at this point in the history
* RichText: Fall back to requestAnimationFrame if no requestIdleCallback
* Fall back to setTimeout(_, 100) if no requestIdleCallback
  • Loading branch information
mcsf committed Aug 27, 2019
1 parent 51ec639 commit 973448f
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion packages/block-editor/src/components/rich-text/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@ import FormatToolbar from './format-toolbar';
import { withBlockEditContext } from '../block-edit/context';
import { RemoveBrowserShortcuts } from './remove-browser-shortcuts';

const requestIdleCallback = window.requestIdleCallback ||
function fallbackRequestIdleCallback( fn ) {
window.setTimeout( fn, 100 );
};

const wrapperClasses = 'editor-rich-text block-editor-rich-text';
const classes = 'editor-rich-text__editable block-editor-rich-text__editable';

Expand Down Expand Up @@ -301,7 +306,7 @@ class RichTextWrapper extends Component {
* ensure all selection changes have been recorded.
*/
markAutomaticChange() {
window.requestIdleCallback( () => {
requestIdleCallback( () => {
this.props.markAutomaticChange();
} );
}
Expand Down

0 comments on commit 973448f

Please sign in to comment.