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] Narrow down blur on unmount to replaceable only #16151

Merged

Conversation

hypest
Copy link
Contributor

@hypest hypest commented Jun 13, 2019

Description

Additional PR on top of #16146, to add more conditions on when to do the blur-on-unmount for the RichText.

In this case, we're passing the isReplaceable flag to the component via the Context, and do the blur-on-unmount only if the parent block is replaceable (in which case it won't have the chance the blur otherwise). Instead of passing it, the latest revision of this fix has the computation of the shouldBlurOnUnmount flag/prop right inside the withSelect HOC of the RichText.

(Embedding the description from #16146 for completeness):
In #15999 this behavior was changed to prevent the keyboard from disappearing
when you press Enter to create a new paragraph.

This worked in that case, but had the side effect of TextInputState still
thinking a dead view had focus, and causing a crash in some scenarios.

Fixes wordpress-mobile/gutenberg-mobile#1126

Screen Recording 2019-06-13 at 09 17 45

To test:

  1. Remove all the content
  2. Insert an image
  3. Remove the image
  4. Ensure there's no crash

Types of changes

Compute and pass isReplaceable to the editing context and use it in RichText to blur.

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.

koke and others added 2 commits June 13, 2019 08:44
In #15999 this behavior was changed to prevent the keyboard from disappearing
when you press Enter to create a new paragraph.

This worked in that case, but had the side effect of TextInputState still
thinking a dead view had focus, and causing a crash in some scenarios.
That RichText won't have the chance to blur earlier so, we need to do it
on unmount. But, non replaceable blocks wont need to blur their RichText
on unmount because that will happen normally in componentDidUpdate().
@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 Jun 13, 2019
@hypest hypest requested review from gziolo and removed request for gziolo June 13, 2019 09:29
@hypest hypest changed the base branch from rnmobile/1126-fix-blur-crash to rnmobile/release-v1.7.0 June 13, 2019 10:30
@hypest hypest requested review from koke and removed request for ellatrix, talldan, youknowriad and gziolo June 13, 2019 10:55
@hypest hypest merged commit 1b03fdb into rnmobile/release-v1.7.0 Jun 13, 2019
@github-actions github-actions bot added this to the Gutenberg 5.10 milestone Jun 13, 2019
@gziolo gziolo modified the milestones: Gutenberg 5.10, Gutenberg 6.0 Jun 14, 2019
hypest added a commit that referenced this pull request Jun 14, 2019
* [Mobile] Disable Video block on Android for v1.7.0 release (#16149)

* Disable Video block on Android for v1.7.0 release

* Add import statement to check platform

* [RNMobile] Narrow down blur on unmount to replaceable only (#16151)

* Remove focus from RichText when unmounting

In #15999 this behavior was changed to prevent the keyboard from disappearing
when you press Enter to create a new paragraph.

This worked in that case, but had the side effect of TextInputState still
thinking a dead view had focus, and causing a crash in some scenarios.

* Only blur a RichText in replaceable block

That RichText won't have the chance to blur earlier so, we need to do it
on unmount. But, non replaceable blocks wont need to blur their RichText
on unmount because that will happen normally in componentDidUpdate().

* Rename to an unstable, very goal-named name

* Compute shouldBlurOnUnmount inside RichText

* Fix no-duplicate-imports lint issue

* Fix comma-dangle lint error

* Remove trailing space from comment
@youknowriad youknowriad deleted the rnmobile/narrow-blur-on-unmount-to-replaceable branch May 27, 2020 17:46
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