Skip to content

Commit

Permalink
Allow focus to be set through onChange
Browse files Browse the repository at this point in the history
  • Loading branch information
ellatrix committed Sep 27, 2019
1 parent fc138bf commit 032d0dd
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
4 changes: 2 additions & 2 deletions packages/format-library/src/link/inline.js
Original file line number Diff line number Diff line change
Expand Up @@ -149,9 +149,9 @@ class InlineLinkUI extends Component {

if ( isCollapsed( value ) && ! isActive ) {
const toInsert = applyFormat( create( { text: url } ), format, 0, url.length );
onChange( insert( value, toInsert ) );
onChange( insert( value, toInsert ), { focus: true } );
} else {
onChange( applyFormat( value, format ) );
onChange( applyFormat( value, format ), { focus: true } );
}

this.resetState();
Expand Down
6 changes: 5 additions & 1 deletion packages/rich-text/src/component/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -527,7 +527,11 @@ class RichText extends Component {
* @param {boolean} $2.withoutHistory If true, no undo level will be
* created.
*/
onChange( record, { withoutHistory } = {} ) {
onChange( record, { withoutHistory, focus } = {} ) {
if ( focus ) {
this.editableRef.focus();
}

this.applyRecord( record );

const { start, end, activeFormats = [] } = record;
Expand Down

0 comments on commit 032d0dd

Please sign in to comment.