-
Notifications
You must be signed in to change notification settings - Fork 803
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
eslint: Enable
@wordpress/no-base-control-with-label-without-id
rule (
#39708) When `<BaseControl>` is passed both a `label` and `id`, it makes an HTML `<label>` so clicking the label focuses the contained element with the corresponding `id`. Leaving off the `id` breaks that, so this rule flags the situation for fixing. It turns out, though, that everything it flagged in the monorepo was a false positive. A few cases we had something like `<BaseControl label><TextControl /></BaseControl>`. There's no reason for that when we can do `<TextControl label />` instead and get the expected click-label-to-focus behavior. The rest of the cases we were using `<BaseControl label>` to get a label for something more complex, where there's really no `id` that makes sense. In this case the documented thing to do is apparently `<BaseControl><BaseControl.VisualLabel>label</BaseControl.VisualLabel></BaseControl>` which does exactly the same thing that `<BaseControl label>` with no `id` does internally.
- Loading branch information
Showing
23 changed files
with
95 additions
and
80 deletions.
There are no files selected for viewing
5 changes: 5 additions & 0 deletions
5
...publicize-components/changelog/add-eslint-wordpress-no-base-control-with-label-without-id
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
Significance: patch | ||
Type: fixed | ||
Comment: Clean up `<BaseControl label>` without `id`. Should be no change in functionality. | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 5 additions & 0 deletions
5
projects/packages/forms/changelog/add-eslint-wordpress-no-base-control-with-label-without-id
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
Significance: patch | ||
Type: fixed | ||
Comment: Clean up `<BaseControl label>` without `id`. Should be no change in functionality. | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 5 additions & 0 deletions
5
.../packages/videopress/changelog/add-eslint-wordpress-no-base-control-with-label-without-id
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
Significance: patch | ||
Type: fixed | ||
Comment: Clean up `<BaseControl label>` without `id`. Should be no change in functionality. | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 5 additions & 0 deletions
5
...ects/plugins/jetpack/changelog/add-eslint-wordpress-no-base-control-with-label-without-id
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
Significance: patch | ||
Type: other | ||
Comment: Clean up `<BaseControl label>` without `id`. Should be no change in functionality, other than in a few cases being able to click the label to focus the field now. | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 6 additions & 10 deletions
16
projects/plugins/jetpack/extensions/blocks/simple-payments/controls.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,21 @@ | ||
import { BaseControl, PanelBody, TextControl } from '@wordpress/components'; | ||
import { PanelBody, TextControl } from '@wordpress/components'; | ||
import { __ } from '@wordpress/i18n'; | ||
|
||
export function PanelControls( { setAttributes, postLinkText } ) { | ||
return ( | ||
<PanelBody title={ __( 'Settings', 'jetpack' ) } initialOpen={ false }> | ||
<BaseControl | ||
<TextControl | ||
__nextHasNoMarginBottom={ true } | ||
label={ __( 'Purchase link text', 'jetpack' ) } | ||
help={ __( | ||
'Enter the text you want to display on a purchase link used as fallback when the PayPal button cannot be used (e.g. emails, AMP, etc.)', | ||
'jetpack' | ||
) } | ||
className="jetpack-simple-payments__purchase-link-text" | ||
> | ||
<TextControl | ||
__nextHasNoMarginBottom={ true } | ||
placeholder={ __( 'Click here to purchase', 'jetpack' ) } | ||
onChange={ newPostLinkText => setAttributes( { postLinkText: newPostLinkText } ) } | ||
value={ postLinkText } | ||
/> | ||
</BaseControl> | ||
placeholder={ __( 'Click here to purchase', 'jetpack' ) } | ||
onChange={ newPostLinkText => setAttributes( { postLinkText: newPostLinkText } ) } | ||
value={ postLinkText } | ||
/> | ||
</PanelBody> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.