Skip to content

Commit

Permalink
TreeSelect: remove margin overrides and add new opt-in prop (#47515)
Browse files Browse the repository at this point in the history
* TreeSelect: remove margin overrides and add new opt-in prop

* Update changelog

* Add VStack spacing

* Add margin override to Latest Posts block to adjust for QueryControls spacing

* Update to consistent spacing

* Add Lena’s suggestion to override basecontrol margin for query control

* Remove bottom margin from formtokenfield

* Remove unnecessary CSS
  • Loading branch information
brookewp committed Mar 30, 2023
1 parent a77f40c commit 90258ed
Show file tree
Hide file tree
Showing 7 changed files with 48 additions and 51 deletions.
10 changes: 6 additions & 4 deletions packages/block-editor/src/components/block-inspector/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,12 @@
}
}

// Reset unexpected margin-bottom from being applied to the `BaseControl`
// component of the `FocalPointPicker` component.
.components-focal-point-picker-control .components-base-control {
margin-bottom: 0;
// Reset unwanted margin-bottom from being applied to BaseControls within certain components.
.components-focal-point-picker-control,
.components-query-controls {
.components-base-control {
margin-bottom: 0;
}
}

.components-panel__body {
Expand Down
9 changes: 5 additions & 4 deletions packages/components/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,19 @@
- `ColorPicker`: Convert to TypeScript ([#49214](https://github.com/WordPress/gutenberg/pull/49214)).
- `GradientPicker`: Convert to TypeScript ([#48316](https://github.com/WordPress/gutenberg/pull/48316)).
- `FormTokenField`: Add a `__nextHasNoMarginBottom` prop to start opting into the margin-free styles ([48609](https://github.com/WordPress/gutenberg/pull/48609)).
- `QueryControls`: Replace bottom margin overrides with `__nextHasNoMarginBottom`([47515](https://github.com/WordPress/gutenberg/pull/47515)).

### Enhancements

- `CustomGradientPicker`: improve initial state UI ([#49146](https://github.com/WordPress/gutenberg/pull/49146)).
- `AnglePickerControl`: Style to better fit in narrow contexts and improve RTL layout ([#49046](https://github.com/WordPress/gutenberg/pull/49046)).
- `AnglePickerControl`: Style to better fit in narrow contexts and improve RTL layout ([#49046](https://github.com/WordPress/gutenberg/pull/49046)).
- `ImageSizeControl`: Use large 40px sizes ([#49113](https://github.com/WordPress/gutenberg/pull/49113)).

### Bug Fix

- `CircularOptionPicker`: force swatches to visually render on top of the rest of the component's content ([#49245](https://github.com/WordPress/gutenberg/pull/49245)).
- `InputControl`: Fix misaligned textarea input control ([#49116](https://github.com/WordPress/gutenberg/pull/49116)).
- `ToolsPanel`: Ensure consistency in menu item order ([#49222](https://github.com/WordPress/gutenberg/pull/49222)).
- `CircularOptionPicker`: force swatches to visually render on top of the rest of the component's content ([#49245](https://github.com/WordPress/gutenberg/pull/49245)).
- `InputControl`: Fix misaligned textarea input control ([#49116](https://github.com/WordPress/gutenberg/pull/49116)).
- `ToolsPanel`: Ensure consistency in menu item order ([#49222](https://github.com/WordPress/gutenberg/pull/49222)).

### Internal

Expand Down
1 change: 1 addition & 0 deletions packages/components/src/query-controls/author-select.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export default function AuthorSelect( {
? String( selectedAuthorId )
: undefined
}
__nextHasNoMarginBottom
/>
);
}
1 change: 1 addition & 0 deletions packages/components/src/query-controls/category-select.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ export default function CategorySelect( {
: undefined
}
{ ...props }
__nextHasNoMarginBottom
/>
);
}
6 changes: 4 additions & 2 deletions packages/components/src/query-controls/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import CategorySelect from './category-select';
import FormTokenField from '../form-token-field';
import RangeControl from '../range-control';
import SelectControl from '../select-control';
import { VStack } from '../v-stack';
import type {
QueryControlsProps,
QueryControlsWithMultipleCategorySelectionProps,
Expand Down Expand Up @@ -75,7 +76,7 @@ export function QueryControls( {
...props
}: QueryControlsProps ) {
return (
<>
<VStack spacing="4" className="components-query-controls">
{ [
onOrderChange && onOrderByChange && (
<SelectControl
Expand Down Expand Up @@ -142,6 +143,7 @@ export function QueryControls( {
props.categorySuggestions &&
props.onCategoryChange && (
<FormTokenField
__nextHasNoMarginBottom
key="query-controls-categories-select"
label={ __( 'Categories' ) }
value={
Expand Down Expand Up @@ -185,7 +187,7 @@ export function QueryControls( {
/>
),
] }
</>
</VStack>
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ import {
TextControl,
TreeSelect,
withFilters,
__experimentalVStack as VStack,
Flex,
FlexItem,
} from '@wordpress/components';
import { useDispatch, useSelect } from '@wordpress/data';
import { useDebounce } from '@wordpress/compose';
Expand Down Expand Up @@ -392,11 +393,10 @@ export function HierarchicalTermSelector( { slug } ) {
const showFilter = availableTerms.length >= MIN_TERMS_COUNT_FOR_FILTER;

return (
<>
<Flex direction="column" gap="4">
{ showFilter && (
<TextControl
__nextHasNoMarginBottom
className="editor-post-taxonomies__hierarchical-terms-filter"
label={ filterLabel }
value={ filterValue }
onChange={ setFilter }
Expand All @@ -413,18 +413,20 @@ export function HierarchicalTermSelector( { slug } ) {
) }
</div>
{ ! loading && hasCreateAction && (
<Button
onClick={ onToggleForm }
className="editor-post-taxonomies__hierarchical-terms-add"
aria-expanded={ showForm }
variant="link"
>
{ newTermButtonLabel }
</Button>
<FlexItem>
<Button
onClick={ onToggleForm }
className="editor-post-taxonomies__hierarchical-terms-add"
aria-expanded={ showForm }
variant="link"
>
{ newTermButtonLabel }
</Button>
</FlexItem>
) }
{ showForm && (
<form onSubmit={ onAddTerm }>
<VStack>
<Flex direction="column" gap="4">
<TextControl
__nextHasNoMarginBottom
className="editor-post-taxonomies__hierarchical-terms-input"
Expand All @@ -435,24 +437,27 @@ export function HierarchicalTermSelector( { slug } ) {
/>
{ !! availableTerms.length && (
<TreeSelect
__nextHasNoMarginBottom
label={ parentSelectLabel }
noOptionLabel={ noParentOption }
onChange={ onChangeFormParent }
selectedId={ formParent }
tree={ availableTermsTree }
/>
) }
</VStack>
<Button
variant="secondary"
type="submit"
className="editor-post-taxonomies__hierarchical-terms-submit"
>
{ newTermSubmitLabel }
</Button>
<FlexItem>
<Button
variant="secondary"
type="submit"
className="editor-post-taxonomies__hierarchical-terms-submit"
>
{ newTermSubmitLabel }
</Button>
</FlexItem>
</Flex>
</form>
) }
</>
</Flex>
);
}

Expand Down
25 changes: 5 additions & 20 deletions packages/editor/src/components/post-taxonomies/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -10,32 +10,17 @@
}

.editor-post-taxonomies__hierarchical-terms-choice {
margin-bottom: 8px;
margin-bottom: $grid-unit-10;
&:last-child {
margin-bottom: $grid-unit-05;
}
}

.editor-post-taxonomies__hierarchical-terms-subchoices {
margin-top: 8px;
margin-top: $grid-unit-10;
margin-left: $grid-unit-20;
}

.components-button.editor-post-taxonomies__hierarchical-terms-submit,
.components-button.editor-post-taxonomies__hierarchical-terms-add {
margin-top: 12px;
}

.editor-post-taxonomies__hierarchical-terms-label {
display: inline-block;
margin-top: 12px;
}

.editor-post-taxonomies__hierarchical-terms-input {
margin-top: 8px;
}
.editor-post-taxonomies__hierarchical-terms-filter {
margin-bottom: 8px;
width: 100%;
}

.editor-post-taxonomies__flat-term-most-used {
.editor-post-taxonomies__flat-term-most-used-label {
margin-bottom: $grid-unit-05;
Expand Down

1 comment on commit 90258ed

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Flaky tests detected in 90258ed.
Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.

🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/4562651740
📝 Reported issues:

Please sign in to comment.