-
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
Add: ESLint rule that forbids a BaseControl that includes label prop but omits id #14151
Add: ESLint rule that forbids a BaseControl that includes label prop but omits id #14151
Conversation
2143bbd
to
1f91a94
Compare
1f91a94
to
4d0157c
Compare
4d0157c
to
a9824d1
Compare
```jsx | ||
<BaseControl | ||
label="ok" | ||
id="my-id" |
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.
Even if this is technically "correct" by the condition of the lint rule itself, it's still not a good example in that the id
should direct to an input that the BaseControl wraps. Rather than <b>Child</b>
, I'd prefer to see something like <input id="my-id" />
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.
Hi @aduth thank you for the review 👍 Your feedback was addressed.
a9824d1
to
d282f2c
Compare
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 it may be good to wait to see how #14179 shakes out before moving forward on this.
I had a review comment saved, so submitting to have it published.
ref={ this.posterImageButton } | ||
> | ||
{ ! this.props.attributes.poster ? __( 'Select Poster Image' ) : __( 'Replace image' ) } | ||
{ ( |
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.
Out of curiosity, would it not have worked to just do something like?
{ /* TODO: ... */ }
{ /* eslint-disable-next-line @wordpress/no-base-control-with-label-without-id */ }
(avoid the extra nesting level)
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 it would work, I simply used another nesting level because it was the idea that occurred to me.
…14179) ## Description This PR applies a simple change to remove unnecessary BaseControl usage in the video block. It makes the video block code compliant with the lint rule being added on #14151. I tried a different approach use the BaseControl as a label for the button being rendered inside it, but in my tests with a screen reader the button text stops being used and BaseControl label starts getting used, in this case, this change does not make sense, the button text should be used. ## How has this been tested? I checked that the Poster Image buttons still work. I checked that no visual changes happen.
d282f2c
to
af8a8a1
Compare
af8a8a1
to
72c2dc4
Compare
Fixes: #6989
Follows a suggestion by @aduth and creates an eslint rule that forbids a
BaseControl
that includeslabel
prop but omitsid
.Currently, CI is red because some code needs an update. I will submit right away a PR that fixes issue #13894 and makes the code compliant with our lint rule.
For now, I added some ignores, each case has it its complexities. For each, we need to decide if the usage of BaseControl makes sense, if an id should be provided or if the label needs to be removed a new child used instead.
I will submit a PR per case so we can discuss each case separately and make sure we don't create accessibility regressions.