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

@hypest hypest 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.

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 the Mobile App - i.e. Android or iOS Native mobile impl of the block editor. (Note: used in scripts, ping mobile folks to change) label May 29, 2019
@hypest hypest added this to the 5.9 (Gutenberg) milestone May 29, 2019
@hypest hypest requested a review from daniloercoli May 29, 2019 07:54
@SergioEstevao SergioEstevao self-requested a review May 30, 2019 08:54
Copy link
Contributor

@SergioEstevao SergioEstevao left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Working great!

@hypest hypest merged commit 7cef03f into master May 30, 2019
@hypest hypest deleted the rnmobile/signal-the-right-richtext-to-request-focus branch May 30, 2019 12:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Mobile App - i.e. Android or iOS Native mobile impl of the block editor. (Note: used in scripts, ping mobile folks to change)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants