[RNMobile] Fix loss of center alignment in image captions on Android #16722
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR is related to WordPress/gutenberg-mobile#1243.
Description
Addresses an issue where an unwanted
<div>
tag was added to image captions because thedefaultProps
forRichText
specified a div tagName. This was causing the loss of center alignment on image captions in mobile.Background
In order to implement quote blocks,
RichText
was given a default "div"tagName
. This created a problem on Android because AztecEditor-Android creates aHiddenHtmlSpan
out ofdiv
tags, and becauseHiddenHtmlSpan
s extendIAztecParagraphStyle
they default to "normal" text alignment. This overrides the center gravity that is set on the native EditText as a result of the text-align prop being set from the image block.This problem exhibited itself in the loss of center alignment anytime RichText sent html with
div
tags to native for rendering on a view with center alignment (i.e., the image caption). Explicitly setting the image block'stagName
to be an empty string prevents the default "div" tagName from being applied. It would be nice to address this on the native layer (so that div tags didn't override the view's gravity), but any fix at that level would have been very invasive.Test steps
From gutenberg-mobile Issue 1070
From gutenberg-mobile Issue 1113
Checklist: