diff --git a/packages/block-editor/src/components/color-palette/test/__snapshots__/control.js.snap b/packages/block-editor/src/components/color-palette/test/__snapshots__/control.js.snap
index dc65ab06e65512..edfd5531003173 100644
--- a/packages/block-editor/src/components/color-palette/test/__snapshots__/control.js.snap
+++ b/packages/block-editor/src/components/color-palette/test/__snapshots__/control.js.snap
@@ -14,6 +14,31 @@ exports[`ColorPaletteControl matches the snapshot 1`] = `
margin-bottom: inherit;
}
+.emotion-4 {
+ display: -webkit-box;
+ display: -webkit-flex;
+ display: -ms-flexbox;
+ display: flex;
+ -webkit-align-items: normal;
+ -webkit-box-align: normal;
+ -ms-flex-align: normal;
+ align-items: normal;
+ -webkit-flex-direction: column;
+ -ms-flex-direction: column;
+ flex-direction: column;
+ -webkit-box-pack: justify;
+ -webkit-justify-content: space-between;
+ justify-content: space-between;
+}
+
+.emotion-4>*+*:not( marquee ) {
+ margin-top: calc(4px * 2);
+}
+
+.emotion-4>* {
+ min-height: 0;
+}
+
@@ -21,97 +46,103 @@ exports[`ColorPaletteControl matches the snapshot 1`] = `
className="components-base-control__field emotion-2 emotion-3"
>
diff --git a/packages/block-editor/src/components/colors-gradients/control.js b/packages/block-editor/src/components/colors-gradients/control.js
index b69ab19d1aedd0..8ec461342d0936 100644
--- a/packages/block-editor/src/components/colors-gradients/control.js
+++ b/packages/block-editor/src/components/colors-gradients/control.js
@@ -10,8 +10,9 @@ import { every, isEmpty } from 'lodash';
import { useState } from '@wordpress/element';
import {
BaseControl,
- Button,
- ButtonGroup,
+ __experimentalVStack as VStack,
+ __experimentalToggleGroupControl as ToggleGroupControl,
+ __experimentalToggleGroupControlOption as ToggleGroupControlOption,
ColorIndicator,
ColorPalette,
GradientPicker,
@@ -110,66 +111,68 @@ function ColorGradientControlInner( {
) }
>
);
diff --git a/packages/block-editor/src/components/colors-gradients/style.scss b/packages/block-editor/src/components/colors-gradients/style.scss
index 861710065f7612..c3070aa53106b2 100644
--- a/packages/block-editor/src/components/colors-gradients/style.scss
+++ b/packages/block-editor/src/components/colors-gradients/style.scss
@@ -2,11 +2,6 @@
.block-editor-color-gradient-control__color-indicator {
margin-bottom: $grid-unit-15;
}
-
- .block-editor-color-gradient-control__button-tabs {
- display: block;
- margin-bottom: $grid-unit-15;
- }
}
.block-editor-panel-color-gradient-settings {
@@ -45,4 +40,12 @@
margin-right: 0;
}
}
+
+
+ // This shouldn't be needed but there's a rule in the inspector controls
+ // overriding this causing too much spacing.
+ // That generic rule should ideally be removed.
+ .block-editor-block-inspector & .components-base-control {
+ margin-bottom: inherit;
+ }
}
diff --git a/packages/block-editor/src/components/colors-gradients/test/control.js b/packages/block-editor/src/components/colors-gradients/test/control.js
index 5d1eec205b326b..e0de5f5eea1ed7 100644
--- a/packages/block-editor/src/components/colors-gradients/test/control.js
+++ b/packages/block-editor/src/components/colors-gradients/test/control.js
@@ -1,6 +1,7 @@
/**
* External dependencies
*/
+import { render, screen } from '@testing-library/react';
import { create, act } from 'react-test-renderer';
import { noop } from 'lodash';
@@ -27,67 +28,57 @@ const getButtonWithAriaLabelStartPredicate = ( ariaLabelStart ) => (
);
};
-const colorTabButtonPredicate = getButtonWithTestPredicate( 'Solid' );
-const gradientTabButtonPredicate = getButtonWithTestPredicate( 'Gradient' );
+const getTabWithTestPredicate = ( text ) => ( element ) => {
+ return (
+ element.type === 'button' &&
+ element.props[ 'aria-label' ] &&
+ element.props[ 'aria-label' ] === text
+ );
+};
+
+const colorTabButtonPredicate = getTabWithTestPredicate( 'Solid' );
+const gradientTabButtonPredicate = getTabWithTestPredicate( 'Gradient' );
describe( 'ColorPaletteControl', () => {
it( 'renders tabs if it is possible to select a color and a gradient rendering a color picker at the start', async () => {
- let wrapper;
-
- await act( async () => {
- wrapper = create(
-
- );
- } );
+ render(
+
+ );
// Is showing the two tab buttons.
- expect( wrapper.root.findAll( colorTabButtonPredicate ) ).toHaveLength(
- 1
- );
- expect(
- wrapper.root.findAll( gradientTabButtonPredicate )
- ).toHaveLength( 1 );
+ expect( screen.queryByLabelText( 'Solid' ) ).toBeInTheDocument();
+ expect( screen.queryByLabelText( 'Gradient' ) ).toBeInTheDocument();
// Is showing the two predefined Colors.
- expect(
- wrapper.root.findAll(
- ( element ) =>
- element.type === 'button' &&
- element.props &&
- element.props[ 'aria-label' ] &&
- element.props[ 'aria-label' ].startsWith( 'Color:' )
- )
- ).toHaveLength( 2 );
+ expect( screen.getAllByLabelText( /^Color:/ ) ).toHaveLength( 2 );
// Is showing the custom color picker.
- expect(
- wrapper.root.findAll( getButtonWithTestPredicate( 'Custom color' ) )
- ).toHaveLength( 1 );
+ expect( screen.queryByText( 'Custom color' ) ).toBeInTheDocument();
} );
it( 'renders the color picker and does not render tabs if it is only possible to select a color', async () => {