Skip to content

Commit

Permalink
Add margin-bottom lint rules for SelectControl (#64283)
Browse files Browse the repository at this point in the history
* Fix in ResolutionTool

Doesn't matter because this is wrapped in a ToolsPanelItem, which already does normalization on BaseControl margins.

* Fix in test

* Fix in Form block

* Fix in Post Navigation block

* Fix in Font Library ▸ Install Fonts

* Add eslint rule

* Fix in DataForm text field type

* Add prop to JSDoc

* Fix in Query Loop block

* Remove unnecessary additions in DataForm

* TreeSelect: Fix up JSDoc formatting

* Add to InspectorControls readme

Co-authored-by: mirka <[email protected]>
Co-authored-by: tyxla <[email protected]>
  • Loading branch information
3 people authored Aug 7, 2024
1 parent b647825 commit b43e05e
Show file tree
Hide file tree
Showing 11 changed files with 23 additions and 5 deletions.
1 change: 1 addition & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,7 @@ module.exports = {
'FocalPointPicker',
'RangeControl',
'SearchControl',
'SelectControl',
'TextControl',
'TextareaControl',
'ToggleControl',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ registerBlockType( 'my-plugin/inspector-controls-example', {
<InspectorControls>
<PanelBody title={ __( 'Settings' ) }>
<CheckboxControl
__nextHasNoMarginBottom
heading="Checkbox Field"
label="Tick Me"
help="Additional help text"
Expand All @@ -114,19 +115,22 @@ registerBlockType( 'my-plugin/inspector-controls-example', {
/>

<TextControl
__nextHasNoMarginBottom
label="Text Field"
help="Additional help text"
value={ textField }
onChange={ onChangeTextField }
/>

<ToggleControl
__nextHasNoMarginBottom
label="Toggle Field"
checked={ toggleField }
onChange={ onChangeToggleField }
/>

<SelectControl
__nextHasNoMarginBottom
label="Select Control"
value={ selectField }
options={ [
Expand Down Expand Up @@ -203,6 +207,7 @@ function MyBlockEdit( { attributes, setAttributes } ) {
</InspectorControls>
<InspectorAdvancedControls>
<TextControl
__nextHasNoMarginBottom
label="HTML anchor"
value={ attributes.anchor }
onChange={ ( nextValue ) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ export default function ResolutionTool( {
panelId={ panelId }
>
<SelectControl
__nextHasNoMarginBottom
label={ __( 'Resolution' ) }
value={ displayValue }
options={ options }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,11 @@ const sizeOptions = [
const renderTestDefaultControlComponent = ( labelComponent, device ) => {
return (
<>
<SelectControl label={ labelComponent } options={ sizeOptions } />
<SelectControl
label={ labelComponent }
options={ sizeOptions }
__nextHasNoMarginBottom
/>
<p id={ device.id }>
{ device.label } is used here for testing purposes to ensure we
have access to details about the device.
Expand Down
5 changes: 3 additions & 2 deletions packages/block-library/src/form/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,8 @@ const Edit = ( { attributes, setAttributes, clientId } ) => {
<InspectorControls>
<PanelBody title={ __( 'Settings' ) }>
<SelectControl
// __nextHasNoMarginBottom
// size={ '__unstable-large' }
__nextHasNoMarginBottom
__next40pxDefaultSize
label={ __( 'Submissions method' ) }
options={ [
// TODO: Allow plugins to add their own submission methods.
Expand Down Expand Up @@ -108,6 +108,7 @@ const Edit = ( { attributes, setAttributes, clientId } ) => {
{ submissionMethod === 'email' && (
<TextControl
__nextHasNoMarginBottom
__next40pxDefaultSize
autoComplete="off"
label={ __( 'Email for form submissions' ) }
value={ email }
Expand Down
2 changes: 2 additions & 0 deletions packages/block-library/src/post-navigation-link/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,8 @@ export default function PostNavigationLinkEdit( {
</InspectorControls>
<InspectorControls group="advanced">
<SelectControl
__next40pxDefaultSize
__nextHasNoMarginBottom
label={ __( 'Filter by taxonomy' ) }
value={ taxonomy }
options={ getTaxonomyOptions() }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ const orderOptions = [
function OrderControl( { order, orderBy, onChange } ) {
return (
<SelectControl
__nextHasNoMarginBottom
__next40pxDefaultSize
label={ __( 'Order by' ) }
value={ `${ orderBy }/${ order }` }
Expand Down
1 change: 1 addition & 0 deletions packages/components/src/select-control/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ function UnforwardedSelectControl< V extends string >(
*
* return (
* <SelectControl
* __nextHasNoMarginBottom
* label="Size"
* value={ size }
* options={ [
Expand Down
3 changes: 1 addition & 2 deletions packages/components/src/tree-select/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ function getSelectOptions(
*
* return (
* <TreeSelect
* __nextHasNoMarginBottom
* __nextHasNoMarginBottom
* label="Parent page"
* noOptionLabel="No parent page"
* onChange={ ( newPage ) => setPage( newPage ) }
Expand Down Expand Up @@ -73,7 +73,6 @@ function getSelectOptions(
* }
* ```
*/

export function TreeSelect( props: TreeSelectProps ) {
const {
label,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,8 @@ function FontCollection( { slug } ) {
</FlexItem>
<FlexItem>
<SelectControl
__nextHasNoMarginBottom
__next40pxDefaultSize
label={ __( 'Category' ) }
value={ filters.category }
onChange={ handleCategoryFilter }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ $footer-height: 70px;
color: $gray-900;
}

// TODO: See if this can be removed after https://github.com/WordPress/gutenberg/issues/38730
.font-library-modal__tabpanel-layout .components-base-control__field {
margin-bottom: 0;
}
Expand Down

0 comments on commit b43e05e

Please sign in to comment.