-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -39,6 +39,34 @@ import { useFormatTypes } from './use-format-types'; | |||||||||||||||||||||||||||||||||||||||||
import FormatEdit from './format-edit'; | ||||||||||||||||||||||||||||||||||||||||||
import { getMultilineTag, getAllowedFormats } from './utils'; | ||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||
/** | ||||||||||||||||||||||||||||||||||||||||||
* Removes props used for the native version of RichText so that they are not | ||||||||||||||||||||||||||||||||||||||||||
* passed to the DOM element and log warnings. | ||||||||||||||||||||||||||||||||||||||||||
* | ||||||||||||||||||||||||||||||||||||||||||
* @param {Object} props Props to filter. | ||||||||||||||||||||||||||||||||||||||||||
* | ||||||||||||||||||||||||||||||||||||||||||
* @return {Object} Filtered props. | ||||||||||||||||||||||||||||||||||||||||||
*/ | ||||||||||||||||||||||||||||||||||||||||||
function removeNativeProps( props ) { | ||||||||||||||||||||||||||||||||||||||||||
return omit( props, [ | ||||||||||||||||||||||||||||||||||||||||||
'__unstableMobileNoFocusOnMount', | ||||||||||||||||||||||||||||||||||||||||||
'deleteEnter', | ||||||||||||||||||||||||||||||||||||||||||
'placeholderTextColor', | ||||||||||||||||||||||||||||||||||||||||||
'textAlign', | ||||||||||||||||||||||||||||||||||||||||||
'selectionColor', | ||||||||||||||||||||||||||||||||||||||||||
'tagsToEliminate', | ||||||||||||||||||||||||||||||||||||||||||
'rootTagsToEliminate', | ||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 commentThe 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
|
||||||||||||||||||||||||||||||||||||||||||
'disableEditingMenu', | ||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 commentThe 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. |
||||||||||||||||||||||||||||||||||||||||||
'fontSize', | ||||||||||||||||||||||||||||||||||||||||||
'fontFamily', | ||||||||||||||||||||||||||||||||||||||||||
'fontWeight', | ||||||||||||||||||||||||||||||||||||||||||
'fontStyle', | ||||||||||||||||||||||||||||||||||||||||||
'minWidth', | ||||||||||||||||||||||||||||||||||||||||||
'maxWidth', | ||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 commentThe 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 🤔 . |
||||||||||||||||||||||||||||||||||||||||||
'setRef', | ||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could we use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If we use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Would There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good point, yeah, we could forward the ref upstream instead of using |
||||||||||||||||||||||||||||||||||||||||||
] ); | ||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||
function RichTextWrapper( | ||||||||||||||||||||||||||||||||||||||||||
{ | ||||||||||||||||||||||||||||||||||||||||||
children, | ||||||||||||||||||||||||||||||||||||||||||
|
@@ -75,6 +103,7 @@ function RichTextWrapper( | |||||||||||||||||||||||||||||||||||||||||
const instanceId = useInstanceId( RichTextWrapper ); | ||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||
identifier = identifier || instanceId; | ||||||||||||||||||||||||||||||||||||||||||
props = removeNativeProps( props ); | ||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||
const anchorRef = useRef(); | ||||||||||||||||||||||||||||||||||||||||||
const { clientId } = useBlockEditContext(); | ||||||||||||||||||||||||||||||||||||||||||
|
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