Skip to content

Commit

Permalink
Rich Text: Add missing deprecated set focused element prop. (#17421)
Browse files Browse the repository at this point in the history
  • Loading branch information
epiqueras authored and youknowriad committed Sep 14, 2019
1 parent 0da78c7 commit 41920bb
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 0 deletions.
1 change: 1 addition & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions packages/rich-text/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
"@babel/runtime": "^7.4.4",
"@wordpress/compose": "file:../compose",
"@wordpress/data": "file:../data",
"@wordpress/deprecated": "file:../deprecated",
"@wordpress/element": "file:../element",
"@wordpress/escape-html": "file:../escape-html",
"@wordpress/hooks": "file:../hooks",
Expand Down
8 changes: 8 additions & 0 deletions packages/rich-text/src/component/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import { BACKSPACE, DELETE, ENTER, LEFT, RIGHT, SPACE, ESCAPE } from '@wordpress
import { withSelect } from '@wordpress/data';
import { withSafeTimeout, compose } from '@wordpress/compose';
import isShallowEqual from '@wordpress/is-shallow-equal';
import deprecated from '@wordpress/deprecated';

/**
* Internal dependencies
Expand Down Expand Up @@ -298,6 +299,13 @@ class RichText extends Component {
this.rafId = window.requestAnimationFrame( this.onSelectionChange );

document.addEventListener( 'selectionchange', this.onSelectionChange );

if ( this.props.setFocusedElement ) {
deprecated( 'wp.blockEditor.RichText setFocusedElement prop', {
alternative: 'selection state from the block editor store.',
} );
this.props.setFocusedElement( this.props.instanceId );
}
}

onBlur() {
Expand Down

0 comments on commit 41920bb

Please sign in to comment.