-
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
Rename Button describedBy prop to description and deprecate old name. #63486
Conversation
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.
To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
Size Change: +365 B (+0.02%) Total Size: 1.75 MB
ℹ️ View Unchanged
|
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.
This solution makes sense to me, thanks @afercia 👍
I'll let the rest of @WordPress/gutenberg-components review it as it involves some prop deprecation.
I was just curious about which pre-existing instances of describedBy
we choose to address.
@@ -64,7 +64,7 @@ function BlockAlignmentUI( { | |||
} ), | |||
} | |||
: { | |||
toggleProps: { describedBy: __( 'Change alignment' ) }, | |||
toggleProps: { description: __( 'Change alignment' ) }, |
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 see we've not updated the prop to the new one everywhere. Example:
describedBy, |
Is that intended?
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.
Glad to update more occurrences if desired. I think I only searched for occurrences of \tdescribedBy=
and \tdescribedBy:
😆
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 that will make sense since otherwise folks might get unexpected deprecation warnings in core.
92cfa5c
to
45e8c15
Compare
Thanks @tyxla I updated that occurrence and rebased. |
@@ -32,7 +32,7 @@ function AlignmentUI( { | |||
onChange, | |||
alignmentControls = DEFAULT_ALIGNMENT_CONTROLS, | |||
label = __( 'Align text' ), | |||
describedBy = __( 'Change text alignment' ), |
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.
This is probably a breaking change for this component. The easy way to avoid the braking change would be to keep the describedBy
prop, and internally pass it to the description
prop in toggleProps
.
Alternatively, we'd probably need to do something similar to what we've done in Button
, where we support the old version alongside the new version.
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.
@ciampo I understand the potential concern. However, I couldn't find any usage of the describedBy
prop for the AlignmentControl
component. The prop is not even documented in the AlignmentControl readme. This component is used internally in the block-editor, is this change a real concern?
Rather, I'd say it's a good opportunity to document it better. I discovered a few more issues and inconsistencies that I'll detail in a new comment.
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.
This component is used internally in the block-editor
This change would affect the APIs of AlignmentControl
and AlignmentToolbar
, which are both public APIs of the @wordpress/block-editor
package.
However, given that:
- as you mentioned, the property is not documented;
- as you mentioned, we couldn't find any current usages of the prop;
- any user using the old
describedBy
prop won't experience breaking, but only an unexpected description (which fallback to the default "Change text alignment") - the change is an overall improvement and aligns with the changes in the
Button
component;
I agree with you that it's ok to just swap the prop name from describedBy
to describe
The AlignmentControl component of the block editor uses the AlignmentUI component which accepts a few props, including I couldn't find any usage of the In the Table block, the alignment control passes a label prop with value
Screen readers will announce both the label and description, thus providing a very confusing information to usdrs. Screenshots: Inconsistencies with similar componentsThere are two very similar components: BlockAlignmentUI BlockVerticalAlignmentUI I will try to split all the above in a new issue. Native filesI found one more occurrence in the |
Sounds good — you can probably open a new PR(s) directly with changes to better align label and description text.
cc @WordPress/native-mobile (I will also tag you in a code comment to pinpoint the exact change) |
@@ -77,7 +77,7 @@ function BlockAlignmentUI( { | |||
}; | |||
} ), | |||
popoverProps: POPOVER_PROPS, | |||
toggleProps: { describedBy: __( 'Change alignment' ) }, | |||
toggleProps: { description: __( 'Change alignment' ) }, |
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.
@WordPress/native-mobile and @dcalhoun , just a quick check that this change makes sense and doesn't introduce unintended consequences 🙏
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.
@ciampo Thanks for coordinating
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.
This change looks good to me 👍
Pending final review and approval 😄 |
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.
🚀 Thank you for working on this!
Thank you, @afercia 🚀 |
…WordPress#63486) * Rename Button describedBy prop to description and deprecate old name. * Update readme. * Remove leftover and add changelog entry. * Update one more occurrence of describedBy prop. * Update one more describedBy occurrence in BlockAlignmentUI native file. Co-authored-by: afercia <afercia@git.wordpress.org> Co-authored-by: tyxla <tyxla@git.wordpress.org> Co-authored-by: ciampo <mciampini@git.wordpress.org> Co-authored-by: geriux <geriux@git.wordpress.org>
Fixes #63483
What?
The Button
describedBy
prop name is misleading.Why?
Prop names should make clear what they are about and what their value type is.
How?
describedBy
todescription
and deprecates old name.Testing Instructions
Change block type or style
.Outdent list item
.Testing Instructions for Keyboard
Screenshots or screencast