Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[RNMobile] Focus RichText on mount if block is selected and says so #15878

Merged
merged 5 commits into from May 30, 2019

Conversation

@hypest
Copy link
Contributor

commented May 29, 2019

Description

Some blocks have multiple RichText or a RichText among other children. Example: Quote blocks has 2 RichTexts and Image block has a RichText for the caption. We want to control when and which of those RichTexts will request focus. On the web side, the DOM is used to search for a inputbox to focus but on RN, we don't have a DOM to search.

In this PR instead, we make the assumption that a RichText will always request focus if its parent has passed true in isSelected and the parent hasn't inhibited that behavior by using the noFocusOnMount prop.

How has this been tested?

Using this gutenberg-mobile side PR: wordpress-mobile/gutenberg-mobile#1043

Types of changes

Introducing a flag combination for the RichText to determine whether it should request focus upon mounting.

Checklist:

  • My code is tested.
  • My code follows the WordPress code style.
  • My code follows the accessibility standards.
  • My code has proper inline documentation.
  • I've included developer documentation if appropriate.
Focus RichText on mount if block is selected and says so
Some blocks have multiple RichText or a RichText among other children.
Example: Quote blocks has 2 RichTexts and Image block has a RichText for
the caption. We want to control when and which of those RichTexts will
request focus. On the web side, the DOM is used to search for a inputbox
to focus but on RN, we don't have a DOM to search.

Instead, this commit makes the assumption that a RichText always request
focus if its parent has passed `true` in `isSelected` and only if the
parent hasn't inhibited that behavior by using the `noFocusOnMount`
prop.

@hypest hypest added this to the 5.9 (Gutenberg) milestone May 29, 2019

@hypest hypest requested a review from daniloercoli May 29, 2019

@hypest hypest referenced this pull request May 29, 2019

Merged

Focus the right RichText #1043

0 of 1 task complete

@SergioEstevao SergioEstevao self-requested a review May 30, 2019

@hypest hypest requested review from SergioEstevao and daniloercoli May 30, 2019

@SergioEstevao
Copy link
Contributor

left a comment

Working great!

@hypest hypest merged commit 7cef03f into master May 30, 2019

1 check passed

Travis CI - Pull Request Build Passed
Details

@hypest hypest deleted the rnmobile/signal-the-right-richtext-to-request-focus branch May 30, 2019

nicolad added a commit to nicolad/gutenberg that referenced this pull request Jun 15, 2019

[RNMobile] Focus RichText on mount if block is selected and says so (W…
…ordPress#15878)

* Focus RichText on mount if block is selected and says so

Some blocks have multiple RichText or a RichText among other children.
Example: Quote blocks has 2 RichTexts and Image block has a RichText for
the caption. We want to control when and which of those RichTexts will
request focus. On the web side, the DOM is used to search for a inputbox
to focus but on RN, we don't have a DOM to search.

Instead, this commit makes the assumption that a RichText always request
focus if its parent has passed `true` in `isSelected` and only if the
parent hasn't inhibited that behavior by using the `noFocusOnMount`
prop.

* Simplify the passing of noFocusOnMount

* Fix grammar in comment

* Rename prop to mark it as unstable
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.