diff --git a/packages/block-editor/src/components/background-image-control/index.js b/packages/block-editor/src/components/background-image-control/index.js index 19ae858521643e..8251f1afb89b66 100644 --- a/packages/block-editor/src/components/background-image-control/index.js +++ b/packages/block-editor/src/components/background-image-control/index.js @@ -40,7 +40,7 @@ import { getResolvedValue } from '@wordpress/global-styles-engine'; */ import { hasBackgroundImageValue } from '../global-styles/background-panel'; import { - InheritanceResetButton, + InheritanceOriginButton, isGlobalStylesInheritanceEnabled, } from '../global-styles/inheritance'; import { setImmutably } from '../../utils/object'; @@ -232,15 +232,16 @@ function BackgroundControlsPanel( { /> { onReset && ( hasLocalOverride ? ( - { + stylePath="background.backgroundImage" + label={ __( 'Background image' ) } + onReset={ () => { onReset(); // Close the dropdown if open. if ( isOpen ) { onToggle(); } - // Focus the toggle button. focusToggleButton( containerRef ); } } /> diff --git a/packages/block-editor/src/components/block-inspector/index.js b/packages/block-editor/src/components/block-inspector/index.js index d584e02bc5753d..9befc92c159504 100644 --- a/packages/block-editor/src/components/block-inspector/index.js +++ b/packages/block-editor/src/components/block-inspector/index.js @@ -531,7 +531,10 @@ const BlockInspectorSingleBlock = ( { { ! isSectionBlock && ( - + ) } ) } diff --git a/packages/block-editor/src/components/colors-gradients/style.scss b/packages/block-editor/src/components/colors-gradients/style.scss index 0a1ce17eedab73..4d1fc3c7077742 100644 --- a/packages/block-editor/src/components/colors-gradients/style.scss +++ b/packages/block-editor/src/components/colors-gradients/style.scss @@ -129,16 +129,13 @@ $swatch-gap: 12px; } } + // Space for the indicator and the contrast warning is reserved + // unconditionally. Widening the label only when no warning is showing made + // it reflow every time the selected colour crossed the contrast threshold. .block-editor-panel-color-gradient-settings__color-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; - max-width: calc(100% - ($button-size-next-default-40px + $grid-unit-05)); - } - - // Reserve extra space for the always-visible contrast warning icon, - // which sits alongside the hover-revealed reset button. - > button.has-contrast-warning .block-editor-panel-color-gradient-settings__color-name { max-width: calc(100% - ($button-size-next-default-40px + $button-size-small + $grid-unit)); } } @@ -176,11 +173,15 @@ $swatch-gap: 12px; opacity: 1; } - // While a contrast warning is in effect the warning icon occupies the - // far-right slot, so the reset button shifts left to sit beside it. - .block-editor-panel-color-gradient-settings__dropdown.has-contrast-warning + & { - right: $button-size-small + $grid-unit-05; - } +} + +// While an override indicator is present it holds the far-right slot, so the +// contrast warning sits inboard of it. Keying this off the indicator rather +// than the warning is what keeps the indicator still: it never moves when the +// selected colour crosses the contrast threshold, and no space is reserved +// beside it when no warning is showing. +.has-local-override-from-global-styles .block-editor-panel-color-gradient-settings__contrast-warning { + right: $button-size-small + $grid-unit-05; } // Icon-only "Low contrast" warning shown to the right of the color diff --git a/packages/block-editor/src/components/global-styles/background-panel.js b/packages/block-editor/src/components/global-styles/background-panel.js index a974f56daada6d..8752389e48e351 100644 --- a/packages/block-editor/src/components/global-styles/background-panel.js +++ b/packages/block-editor/src/components/global-styles/background-panel.js @@ -386,6 +386,7 @@ export default function BackgroundImagePanel( { { showBackgroundColorControl && ( hasBackgroundColorValue( value ) } resetValue={ resetBackgroundColor } isShownByDefault={ defaultControls.backgroundColor } @@ -433,6 +434,7 @@ export default function BackgroundImagePanel( { { showBackgroundGradientControl && ( hasBackgroundGradientValue( value ) } resetValue={ resetGradient } isShownByDefault={ defaultControls.gradient } @@ -478,6 +480,7 @@ export default function BackgroundImagePanel( { { showLegacyColorGradientControl && ( hasLegacyColorGradientValue( value ) } resetValue={ resetLegacyColorGradient } isShownByDefault={ defaultControls.gradient } diff --git a/packages/block-editor/src/components/global-styles/border-panel.js b/packages/block-editor/src/components/global-styles/border-panel.js index 59444cf7bc1e9f..cbb7b0b164e6e6 100644 --- a/packages/block-editor/src/components/global-styles/border-panel.js +++ b/packages/block-editor/src/components/global-styles/border-panel.js @@ -391,6 +391,7 @@ export default function BorderPanel( { > { ( showBorderWidth || showBorderColor ) && ( { hasValue() && ( hasLocalOverride ? ( - { + stylePath={ stylePath } + label={ label } + onReset={ () => { resetValue(); if ( isOpen ) { onToggle(); } - colorGradientDropdownButtonRef.current?.focus(); } } /> ) : ( diff --git a/packages/block-editor/src/components/global-styles/color-panel.js b/packages/block-editor/src/components/global-styles/color-panel.js index 08b6129418c34a..4b73a065e852e5 100644 --- a/packages/block-editor/src/components/global-styles/color-panel.js +++ b/packages/block-editor/src/components/global-styles/color-panel.js @@ -301,6 +301,7 @@ export default function ColorPanel( { const items = [ showLinkPanel && { key: 'link', + stylePath: 'elements.link.color.text', label: __( 'Link' ), hasValue: hasLink, resetValue: resetLink, @@ -461,6 +462,7 @@ export default function ColorPanel( { items.push( { key: name, + stylePath: `elements.${ name }.color.text`, label: elementLabel, hasValue: hasElement, resetValue: resetElement, diff --git a/packages/block-editor/src/components/global-styles/dimensions-panel.js b/packages/block-editor/src/components/global-styles/dimensions-panel.js index dc8b229a81d4a4..fe4792f7ad6a8a 100644 --- a/packages/block-editor/src/components/global-styles/dimensions-panel.js +++ b/packages/block-editor/src/components/global-styles/dimensions-panel.js @@ -760,6 +760,7 @@ export default function DimensionsPanel( { ) } { showContentSizeControl && ( { hasLocalValue && ( hasLocalOverride ? ( - ) : ( ) } - onClick={ ( event ) => { - // Prevent the click from reaching any wrapping - // `