Skip to content

Commit

Permalink
[RNMobile] Ensure post title gets focused when is notified from nativ…
Browse files Browse the repository at this point in the history
…e side (#41371)
  • Loading branch information
fluiddot committed May 26, 2022
1 parent 6eed454 commit 9bdf1b7
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions packages/edit-post/src/editor.native.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,9 @@ class Editor extends Component {
() => {
if ( this.postTitleRef ) {
this.postTitleRef.focus();
} else {
// If the post title ref is not available, we postpone setting focus to when it's available.
this.focusTitleWhenAvailable = true;
}
}
);
Expand Down Expand Up @@ -122,6 +125,11 @@ class Editor extends Component {
}

setTitleRef( titleRef ) {
if ( this.focusTitleWhenAvailable && ! this.postTitleRef ) {
this.focusTitleWhenAvailable = false;
titleRef.focus();
}

this.postTitleRef = titleRef;
}

Expand Down

0 comments on commit 9bdf1b7

Please sign in to comment.