-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Rich text: fix props on DOM element warnings #31883
Conversation
'fontStyle', | ||
'minWidth', | ||
'maxWidth', | ||
'setRef', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we use ref
here instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we use ref
we would get the reference of the RichText
component, right? If that's the case, it won't work because here what we need is the reference of the underneath native view of Aztec (RCTAztecView
).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would forwardRef
not work?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point, yeah, we could forward the ref upstream instead of using setRef
👍 .
'fontWeight', | ||
'fontStyle', | ||
'minWidth', | ||
'maxWidth', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a style equivalent for Native to avoid all these style props?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think in theory we could extract them from the style object that is passed to the native view 🤔 .
'selectionColor', | ||
'tagsToEliminate', | ||
'rootTagsToEliminate', | ||
'disableEditingMenu', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What does this do? What is being disabled?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's used to control triggering the suggestions by keycodes, besides for iOS, this value also determines whether the user can edit the attributes of the text in the text field.
'textAlign', | ||
'selectionColor', | ||
'tagsToEliminate', | ||
'rootTagsToEliminate', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What does this do? :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These props are used to clean up any undesired tags produced by Aztec (the native renderer we use for rich text), here is the related code:
gutenberg/packages/rich-text/src/component/index.native.js
Lines 247 to 266 in c290539
/* | |
* Cleans up any root tags produced by aztec. | |
* TODO: This should be removed on a later version when aztec doesn't return the top tag of the text being edited | |
*/ | |
removeRootTagsProduceByAztec( html ) { | |
let result = this.removeRootTag( this.props.tagName, html ); | |
// Temporary workaround for https://github.com/WordPress/gutenberg/pull/13763 | |
if ( this.props.rootTagsToEliminate ) { | |
this.props.rootTagsToEliminate.forEach( ( element ) => { | |
result = this.removeRootTag( element, result ); | |
} ); | |
} | |
if ( this.props.tagsToEliminate ) { | |
this.props.tagsToEliminate.forEach( ( element ) => { | |
result = this.removeTag( element, result ); | |
} ); | |
} | |
return result; | |
} |
'deleteEnter', | ||
'placeholderTextColor', | ||
'textAlign', | ||
'selectionColor', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should a block be able to set selection color?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we do still want this though as it enables a bit of control over color accessibility. The problem is that the selection highlight box and cursor can blend into the block's background color when we only use the platform's Native color choice. For the case of buttons, we have it set to match the text color as an attempt to provide some contrast.
Here's the original issue that was opened for this to get some more context wordpress-mobile/gutenberg-mobile#1773
Size Change: +117 B (0%) Total Size: 1.3 MB
ℹ️ View Unchanged
|
In most cases, these props are required by the native module that we use for rendering rich text (Aztec). I've gone by one by one and add a brief description of the purpose:
|
Let's merge this PR so we get rid of the warnings. Perhaps we should mark all these props unstable until we can find a common solution for both web and native. |
@ellatrix It should be safe to merge this PR as it only involves changes in the web version of |
@fluiddot The props are set by the block, but for web the props don't do anything and they are passed to the DOM element, for which React logs a warning. |
Description
These props are only used for the native version on RichText and should be removed before passing props to the DOM element, otherwise warnings are logged.
We should also better align on these props. They were all added as stable props to RichText, yet we don't intend so support them for the web version.
@hypest Could we get some clarification as to why each of these props are needed?
How has this been tested?
Screenshots
Types of changes
Checklist:
*.native.js
files for terms that need renaming or removal).