From b8bfb4d8b5827414d9f9445dbf3ec89dd416c022 Mon Sep 17 00:00:00 2001
From: George Mamadashvili
Date: Fri, 6 Dec 2024 13:12:28 +0400
Subject: [PATCH 01/23] Site Editor: Wrap each router area in 'ErrorBoundary'
(#64245)
* Use the error boundary from the `editor` package in the Site Editor.
* Update the `ErrorBoundary` markup and remove the `Warning` component. It still matches the design.
* Update letter casing for button labels.
* Change "Copy post text" to "Copy contents" and make the action label more general.
* Make the "Copy contents" action opt-in.
* Use the primary button variant for "Copy error".
Co-authored-by: Mamaduka
Co-authored-by: youknowriad
Co-authored-by: jasmussen
---
.../edit-post/src/components/layout/index.js | 2 +-
.../src/components/error-boundary/index.js | 44 ------------------
.../error-boundary/test/error-boundary.js | 40 ----------------
.../src/components/error-boundary/warning.js | 30 ------------
.../edit-site/src/components/layout/index.js | 12 +++--
.../src/components/error-boundary/index.js | 46 ++++++++++++-------
.../src/components/error-boundary/style.scss | 6 ++-
7 files changed, 43 insertions(+), 137 deletions(-)
delete mode 100644 packages/edit-site/src/components/error-boundary/index.js
delete mode 100644 packages/edit-site/src/components/error-boundary/test/error-boundary.js
delete mode 100644 packages/edit-site/src/components/error-boundary/warning.js
diff --git a/packages/edit-post/src/components/layout/index.js b/packages/edit-post/src/components/layout/index.js
index c230738a077d9..b0a2b3f7d76b8 100644
--- a/packages/edit-post/src/components/layout/index.js
+++ b/packages/edit-post/src/components/layout/index.js
@@ -548,7 +548,7 @@ function Layout( {
return (
-
+
- );
- }
-}
diff --git a/packages/edit-site/src/components/error-boundary/test/error-boundary.js b/packages/edit-site/src/components/error-boundary/test/error-boundary.js
deleted file mode 100644
index 27ec4c8041967..0000000000000
--- a/packages/edit-site/src/components/error-boundary/test/error-boundary.js
+++ /dev/null
@@ -1,40 +0,0 @@
-/**
- * External dependencies
- */
-import { render } from '@testing-library/react';
-
-/**
- * WordPress dependencies
- */
-import * as wpHooks from '@wordpress/hooks';
-
-/**
- * Internal dependencies
- */
-import ErrorBoundary from '../index';
-
-const theError = new Error( 'Kaboom' );
-
-const ChildComponent = () => {
- throw theError;
-};
-
-describe( 'Error Boundary', () => {
- describe( 'when error is thrown from a Child component', () => {
- it( 'calls the `editor.ErrorBoundary.errorLogged` hook action with the error object', () => {
- const doAction = jest.spyOn( wpHooks, 'doAction' );
-
- render(
-
-
-
- );
-
- expect( doAction ).toHaveBeenCalledWith(
- 'editor.ErrorBoundary.errorLogged',
- theError
- );
- expect( console ).toHaveErrored();
- } );
- } );
-} );
diff --git a/packages/edit-site/src/components/error-boundary/warning.js b/packages/edit-site/src/components/error-boundary/warning.js
deleted file mode 100644
index c4090c7e6b119..0000000000000
--- a/packages/edit-site/src/components/error-boundary/warning.js
+++ /dev/null
@@ -1,30 +0,0 @@
-/**
- * WordPress dependencies
- */
-import { __ } from '@wordpress/i18n';
-import { Button } from '@wordpress/components';
-import { Warning } from '@wordpress/block-editor';
-import { useCopyToClipboard } from '@wordpress/compose';
-
-function CopyButton( { text, children } ) {
- const ref = useCopyToClipboard( text );
- return (
-
- );
-}
-
-export default function ErrorBoundaryWarning( { message, error } ) {
- const actions = [
-
- { __( 'Copy Error' ) }
- ,
- ];
-
- return (
-
- { message }
-
- );
-}
diff --git a/packages/edit-site/src/components/layout/index.js b/packages/edit-site/src/components/layout/index.js
index e7606c57a7048..00bc323ea1535 100644
--- a/packages/edit-site/src/components/layout/index.js
+++ b/packages/edit-site/src/components/layout/index.js
@@ -25,6 +25,7 @@ import { privateApis as blockEditorPrivateApis } from '@wordpress/block-editor';
import {
EditorSnackbars,
UnsavedChangesWarning,
+ ErrorBoundary,
privateApis as editorPrivateApis,
} from '@wordpress/editor';
import { privateApis as coreCommandsPrivateApis } from '@wordpress/core-commands';
@@ -36,7 +37,6 @@ import { useDispatch } from '@wordpress/data';
/**
* Internal dependencies
*/
-import ErrorBoundary from '../error-boundary';
import { default as SiteHub, SiteHubMobile } from '../site-hub';
import ResizableFrame from '../resizable-frame';
import { unlock } from '../../lock-unlock';
@@ -136,7 +136,9 @@ function Layout() {
}
routeKey={ routeKey }
>
- { areas.sidebar }
+
+ { areas.sidebar }
+
@@ -160,7 +162,7 @@ function Layout() {
/>
) }
- { areas.mobile }
+ { areas.mobile }
) }
@@ -173,7 +175,7 @@ function Layout() {
maxWidth: widths?.content,
} }
>
- { areas.content }
+ { areas.content }
) }
@@ -184,7 +186,7 @@ function Layout() {
maxWidth: widths?.edit,
} }
>
- { areas.edit }
+ { areas.edit }
) }
diff --git a/packages/editor/src/components/error-boundary/index.js b/packages/editor/src/components/error-boundary/index.js
index d43af5a556b67..f3e6e5fd127af 100644
--- a/packages/editor/src/components/error-boundary/index.js
+++ b/packages/editor/src/components/error-boundary/index.js
@@ -3,9 +3,12 @@
*/
import { Component } from '@wordpress/element';
import { __ } from '@wordpress/i18n';
-import { Button } from '@wordpress/components';
+import {
+ Button,
+ __experimentalHStack as HStack,
+ __experimentalText as Text,
+} from '@wordpress/components';
import { select } from '@wordpress/data';
-import { Warning } from '@wordpress/block-editor';
import { useCopyToClipboard } from '@wordpress/compose';
import { doAction } from '@wordpress/hooks';
@@ -26,10 +29,10 @@ function getContent() {
} catch ( error ) {}
}
-function CopyButton( { text, children } ) {
+function CopyButton( { text, children, variant = 'secondary' } ) {
const ref = useCopyToClipboard( text );
return (
-
- { ( Children.count( actions ) > 0 || secondaryActions ) && (
+ { ( actions?.length > 0 || secondaryActions ) && (
- { Children.count( actions ) > 0 &&
- Children.map( actions, ( action, i ) => (
+ { actions?.length > 0 &&
+ actions.map( ( action, i ) => (
{
it( 'should show primary actions', () => {
render(
- Click me }>Message
+ Click me ] }>
+ Message
+
);
expect(
From b062f3ec6b9de95adb5fd2ff8d38397324f6aff7 Mon Sep 17 00:00:00 2001
From: Marin Atanasov <8436925+tyxla@users.noreply.github.com>
Date: Fri, 6 Dec 2024 12:24:00 +0200
Subject: [PATCH 03/23] Storybook: Fix BlockPatternsList fixtures (#67672)
Co-authored-by: tyxla
Co-authored-by: Mamaduka
---
.../src/components/block-patterns-list/stories/fixtures.js | 1 +
1 file changed, 1 insertion(+)
diff --git a/packages/block-editor/src/components/block-patterns-list/stories/fixtures.js b/packages/block-editor/src/components/block-patterns-list/stories/fixtures.js
index 0fd895bbe1716..7825ad0d1391c 100644
--- a/packages/block-editor/src/components/block-patterns-list/stories/fixtures.js
+++ b/packages/block-editor/src/components/block-patterns-list/stories/fixtures.js
@@ -530,6 +530,7 @@ export default [
background: '#000000',
},
},
+ tagName: 'hr',
},
innerBlocks: [],
originalContent:
From b6cfa1e24129e3fd51284d5f407fd069f31307aa Mon Sep 17 00:00:00 2001
From: Marin Atanasov <8436925+tyxla@users.noreply.github.com>
Date: Fri, 6 Dec 2024 12:24:12 +0200
Subject: [PATCH 04/23] Popover: Use anchor instead of anchorRef in story
(#67674)
Co-authored-by: tyxla
Co-authored-by: Mamaduka
---
packages/components/src/popover/stories/index.story.tsx | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/packages/components/src/popover/stories/index.story.tsx b/packages/components/src/popover/stories/index.story.tsx
index cf1bd5135ad9f..1e1d4225bd023 100644
--- a/packages/components/src/popover/stories/index.story.tsx
+++ b/packages/components/src/popover/stories/index.story.tsx
@@ -58,7 +58,9 @@ const meta: Meta< typeof Popover > = {
export default meta;
const PopoverWithAnchor = ( args: PopoverProps ) => {
- const anchorRef = useRef( null );
+ const [ popoverAnchor, setPopoverAnchor ] = useState< Element | null >(
+ null
+ );
return (
);
};
From 7cd4a7ebcd16c8526acbcbe67e026eba7284c44e Mon Sep 17 00:00:00 2001
From: Marin Atanasov <8436925+tyxla@users.noreply.github.com>
Date: Fri, 6 Dec 2024 12:32:20 +0200
Subject: [PATCH 05/23] Theme: Fix contrast in nested story (#67681)
Co-authored-by: tyxla
Co-authored-by: Mamaduka
---
packages/components/src/theme/stories/index.story.tsx | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/packages/components/src/theme/stories/index.story.tsx b/packages/components/src/theme/stories/index.story.tsx
index 67eec72533ff3..8ef87cbe8ddb4 100644
--- a/packages/components/src/theme/stories/index.story.tsx
+++ b/packages/components/src/theme/stories/index.story.tsx
@@ -37,7 +37,7 @@ export const Default = Template.bind( {} );
Default.args = {};
export const Nested: StoryFn< typeof Theme > = ( args ) => (
-
+
Outer theme (hardcoded)
From 71c6fb6ffd07aa7ab1ab6826fd4612e4c0bce079 Mon Sep 17 00:00:00 2001
From: Marin Atanasov <8436925+tyxla@users.noreply.github.com>
Date: Fri, 6 Dec 2024 12:42:50 +0200
Subject: [PATCH 06/23] Disabled: Suppress contentEditable warning in story
(#67679)
Co-authored-by: tyxla
Co-authored-by: Mamaduka
---
packages/components/src/disabled/stories/index.story.tsx | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/packages/components/src/disabled/stories/index.story.tsx b/packages/components/src/disabled/stories/index.story.tsx
index 7a42da71f8efe..f017305507814 100644
--- a/packages/components/src/disabled/stories/index.story.tsx
+++ b/packages/components/src/disabled/stories/index.story.tsx
@@ -82,7 +82,7 @@ Default.args = {
export const ContentEditable: StoryFn< typeof Disabled > = ( args ) => {
return (
-
+
contentEditable
From a0c4c614af03362df356bef790e2f7de1553d44c Mon Sep 17 00:00:00 2001
From: Marin Atanasov <8436925+tyxla@users.noreply.github.com>
Date: Fri, 6 Dec 2024 13:23:14 +0200
Subject: [PATCH 07/23] Scrollable: Fix story by declaring field as readonly
(#67683)
Co-authored-by: tyxla
Co-authored-by: Mamaduka
---
packages/components/src/scrollable/stories/index.story.tsx | 1 +
1 file changed, 1 insertion(+)
diff --git a/packages/components/src/scrollable/stories/index.story.tsx b/packages/components/src/scrollable/stories/index.story.tsx
index 318a841f22978..4970b3720e8a0 100644
--- a/packages/components/src/scrollable/stories/index.story.tsx
+++ b/packages/components/src/scrollable/stories/index.story.tsx
@@ -70,6 +70,7 @@ const Template: StoryFn< typeof Scrollable > = ( { ...args } ) => {
} }
type="text"
value="Focus me"
+ readOnly
/>
From 0d7312bc3f412e0a82d697162ac8b0f855fd6be0 Mon Sep 17 00:00:00 2001
From: Marin Atanasov <8436925+tyxla@users.noreply.github.com>
Date: Fri, 6 Dec 2024 13:23:28 +0200
Subject: [PATCH 08/23] DateTime: Add default date/time to stories (#67678)
Co-authored-by: tyxla
Co-authored-by: Mamaduka
---
packages/components/src/date-time/stories/date-time.story.tsx | 3 +++
packages/components/src/date-time/stories/date.story.tsx | 3 +++
packages/components/src/date-time/stories/time.story.tsx | 3 +++
3 files changed, 9 insertions(+)
diff --git a/packages/components/src/date-time/stories/date-time.story.tsx b/packages/components/src/date-time/stories/date-time.story.tsx
index 0c6af3f53fa19..e240b9da47056 100644
--- a/packages/components/src/date-time/stories/date-time.story.tsx
+++ b/packages/components/src/date-time/stories/date-time.story.tsx
@@ -51,6 +51,9 @@ const Template: StoryFn< typeof DateTimePicker > = ( {
};
export const Default: StoryFn< typeof DateTimePicker > = Template.bind( {} );
+Default.args = {
+ currentDate: new Date(),
+};
export const WithEvents: StoryFn< typeof DateTimePicker > = Template.bind( {} );
WithEvents.args = {
diff --git a/packages/components/src/date-time/stories/date.story.tsx b/packages/components/src/date-time/stories/date.story.tsx
index ae4816809f786..d305edf7a29e1 100644
--- a/packages/components/src/date-time/stories/date.story.tsx
+++ b/packages/components/src/date-time/stories/date.story.tsx
@@ -51,6 +51,9 @@ const Template: StoryFn< typeof DatePicker > = ( {
};
export const Default: StoryFn< typeof DatePicker > = Template.bind( {} );
+Default.args = {
+ currentDate: new Date(),
+};
export const WithEvents: StoryFn< typeof DatePicker > = Template.bind( {} );
WithEvents.args = {
diff --git a/packages/components/src/date-time/stories/time.story.tsx b/packages/components/src/date-time/stories/time.story.tsx
index 12e5574115a6c..5497b1e84138c 100644
--- a/packages/components/src/date-time/stories/time.story.tsx
+++ b/packages/components/src/date-time/stories/time.story.tsx
@@ -52,6 +52,9 @@ const Template: StoryFn< typeof TimePicker > = ( {
};
export const Default: StoryFn< typeof TimePicker > = Template.bind( {} );
+Default.args = {
+ currentTime: new Date(),
+};
const TimeInputTemplate: StoryFn< typeof TimePicker.TimeInput > = ( args ) => {
return ;
From bad9281d78fae3692c139119d9a889e9919ceb51 Mon Sep 17 00:00:00 2001
From: Marin Atanasov <8436925+tyxla@users.noreply.github.com>
Date: Fri, 6 Dec 2024 14:07:46 +0200
Subject: [PATCH 09/23] Storybook: Fix table markup in Design Language - Radius
docs (#67686)
Co-authored-by: tyxla
Co-authored-by: Mamaduka
---
.../foundations/design-language/radius.mdx | 46 ++++++++++---------
1 file changed, 25 insertions(+), 21 deletions(-)
diff --git a/storybook/stories/foundations/design-language/radius.mdx b/storybook/stories/foundations/design-language/radius.mdx
index 9117bf940d45a..fda9bcdb85219 100644
--- a/storybook/stories/foundations/design-language/radius.mdx
+++ b/storybook/stories/foundations/design-language/radius.mdx
@@ -31,25 +31,29 @@ These steps are defined as tokens. To view the values and understand how to use
- Accessibility: Larger radius values can create a more approachable and friendly appearance, especially for larger components like cards and modals that demand more attention from users.
-
- ✅ Do |
- 🚫 Don't |
-
-
-
-
-
- - Scale application of radius with element or container size.
-
- - Use `radius-round` for circles and `radius-full` for pills.
- |
-
-
-
- - Don't nest larger radii inside smaller radii.
-
- - Don't apply the same
- radius value to container and immediate descendent.
- |
-
+
+
+ ✅ Do |
+ 🚫 Don't |
+
+
+
+
+
+
+
+ - Scale application of radius with element or container size.
+
+ - Use `radius-round` for circles and `radius-full` for pills.
+ |
+
+
+
+ - Don't nest larger radii inside smaller radii.
+
+ - Don't apply the same
+ radius value to container and immediate descendent.
+ |
+
+
From 4251bbdbf43d19a830a313c01edad138334e0a0d Mon Sep 17 00:00:00 2001
From: Marin Atanasov <8436925+tyxla@users.noreply.github.com>
Date: Fri, 6 Dec 2024 14:43:35 +0200
Subject: [PATCH 10/23] Storybook: Fix storybook blocks imports (#67684)
Co-authored-by: tyxla
Co-authored-by: Mamaduka
---
storybook/stories/foundations/design-language/elevation.mdx | 2 +-
storybook/stories/foundations/design-language/radius.mdx | 2 +-
storybook/stories/tokens/elevation.mdx | 2 +-
storybook/stories/tokens/typography.mdx | 2 +-
4 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/storybook/stories/foundations/design-language/elevation.mdx b/storybook/stories/foundations/design-language/elevation.mdx
index 11591568b3600..fcacfd2ee5a8d 100644
--- a/storybook/stories/foundations/design-language/elevation.mdx
+++ b/storybook/stories/foundations/design-language/elevation.mdx
@@ -1,4 +1,4 @@
-import { Meta, Typeset } from '@storybook/addon-docs/blocks';
+import { Meta, Typeset } from '@storybook/blocks';
import elevation from './static/elevation.svg';
import elevationExamples from './static/elevation-examples.svg';
diff --git a/storybook/stories/foundations/design-language/radius.mdx b/storybook/stories/foundations/design-language/radius.mdx
index fda9bcdb85219..2cf5b05a92efe 100644
--- a/storybook/stories/foundations/design-language/radius.mdx
+++ b/storybook/stories/foundations/design-language/radius.mdx
@@ -1,4 +1,4 @@
-import { Meta, Typeset } from '@storybook/addon-docs/blocks';
+import { Meta, Typeset } from '@storybook/blocks';
import radius from './static/radius.svg';
import radiusDo from './static/radius-do.svg';
import radiusDont from './static/radius-dont.svg';
diff --git a/storybook/stories/tokens/elevation.mdx b/storybook/stories/tokens/elevation.mdx
index 5afb7e75266c4..b3b0cd1a881b4 100644
--- a/storybook/stories/tokens/elevation.mdx
+++ b/storybook/stories/tokens/elevation.mdx
@@ -1,4 +1,4 @@
-import { Meta } from '@storybook/addon-docs/blocks';
+import { Meta } from '@storybook/blocks';
import { TokensTable } from './components.tsx';
diff --git a/storybook/stories/tokens/typography.mdx b/storybook/stories/tokens/typography.mdx
index c3b49b2865f18..9d0e4aedf8c01 100644
--- a/storybook/stories/tokens/typography.mdx
+++ b/storybook/stories/tokens/typography.mdx
@@ -1,4 +1,4 @@
-import { Meta, Typeset } from '@storybook/addon-docs/blocks';
+import { Meta, Typeset } from '@storybook/blocks';
From 5896920781c52b73b256445df12492826f9d2b91 Mon Sep 17 00:00:00 2001
From: Riad Benguella
Date: Fri, 6 Dec 2024 14:15:21 +0100
Subject: [PATCH 11/23] RangeControl: Update the default marks styles to match
the padding/margin control (#67611)
Co-authored-by: youknowriad
Co-authored-by: ciampo
Co-authored-by: jasmussen
Co-authored-by: mirka <0mirka00@git.wordpress.org>
Co-authored-by: ntsekouras
Co-authored-by: jameskoster
---
.../spacing-sizes-control/style.scss | 29 ---------------
packages/components/CHANGELOG.md | 1 +
.../components/src/range-control/mark.tsx | 1 -
.../styles/range-control-styles.ts | 37 +++++++++----------
4 files changed, 19 insertions(+), 49 deletions(-)
diff --git a/packages/block-editor/src/components/spacing-sizes-control/style.scss b/packages/block-editor/src/components/spacing-sizes-control/style.scss
index a387e5369d01e..26f3dc586bb54 100644
--- a/packages/block-editor/src/components/spacing-sizes-control/style.scss
+++ b/packages/block-editor/src/components/spacing-sizes-control/style.scss
@@ -4,40 +4,11 @@
margin-bottom: 0;
}
- .is-marked {
- .components-range-control__track {
- transition: width ease 0.1s;
- @include reduce-motion("transition");
- }
-
- .components-range-control__thumb-wrapper {
- transition: left ease 0.1s;
- @include reduce-motion("transition");
- }
- }
-
.spacing-sizes-control__range-control,
.spacing-sizes-control__custom-value-range {
flex: 1;
margin-bottom: 0; // Needed for some instances of the range control, such as the Spacer block.
}
-
- .components-range-control__mark {
- transform: translateX(-50%);
- height: $grid-unit-05;
- width: math.div($grid-unit-05, 2);
- background-color: $white;
- z-index: 1;
- top: -#{$grid-unit-05};
- }
-
- .components-range-control__marks {
- margin-top: 17px;
- }
-
- .components-range-control__thumb-wrapper {
- z-index: 3;
- }
}
.spacing-sizes-control__header {
diff --git a/packages/components/CHANGELOG.md b/packages/components/CHANGELOG.md
index 1fd87cc958352..2d2761924fb63 100644
--- a/packages/components/CHANGELOG.md
+++ b/packages/components/CHANGELOG.md
@@ -10,6 +10,7 @@
- `GradientPicker`: Add `enableAlpha` prop ([#66974](https://github.com/WordPress/gutenberg/pull/66974))
- `CustomGradientPicker`: Add `enableAlpha` prop ([#66974](https://github.com/WordPress/gutenberg/pull/66974))
+- `RangeControl`: Update the design of the range control marks ([#67611](https://github.com/WordPress/gutenberg/pull/67611))
### Deprecations
diff --git a/packages/components/src/range-control/mark.tsx b/packages/components/src/range-control/mark.tsx
index a17665bb628ab..8692db679f256 100644
--- a/packages/components/src/range-control/mark.tsx
+++ b/packages/components/src/range-control/mark.tsx
@@ -38,7 +38,6 @@ export default function RangeMark(
{ ...otherProps }
aria-hidden="true"
className={ classes }
- isFilled={ isFilled }
style={ style }
/>
{ label && (
diff --git a/packages/components/src/range-control/styles/range-control-styles.ts b/packages/components/src/range-control/styles/range-control-styles.ts
index 6e9c68ace9753..d943ca472911e 100644
--- a/packages/components/src/range-control/styles/range-control-styles.ts
+++ b/packages/components/src/range-control/styles/range-control-styles.ts
@@ -130,6 +130,10 @@ export const Track = styled.span`
margin-top: ${ ( rangeHeightValue - railHeight ) / 2 }px;
top: 0;
+ @media not ( prefers-reduced-motion ) {
+ transition: width ease 0.1s;
+ }
+
${ trackBackgroundColor };
`;
@@ -139,28 +143,18 @@ export const MarksWrapper = styled.span`
position: relative;
width: 100%;
user-select: none;
+ margin-top: 17px;
`;
-const markFill = ( { disabled, isFilled }: RangeMarkProps ) => {
- let backgroundColor = isFilled ? 'currentColor' : COLORS.gray[ 300 ];
-
- if ( disabled ) {
- backgroundColor = COLORS.gray[ 400 ];
- }
-
- return css( {
- backgroundColor,
- } );
-};
-
export const Mark = styled.span`
- height: ${ thumbSize }px;
- left: 0;
position: absolute;
- top: 9px;
- width: 1px;
-
- ${ markFill };
+ left: 0;
+ top: -4px;
+ height: 4px;
+ width: 2px;
+ transform: translateX( -50% );
+ background-color: ${ COLORS.ui.background };
+ z-index: 1;
`;
const markLabelFill = ( { isFilled }: RangeMarkProps ) => {
@@ -173,7 +167,7 @@ export const MarkLabel = styled.span`
color: ${ COLORS.gray[ 300 ] };
font-size: 11px;
position: absolute;
- top: 22px;
+ top: 8px;
white-space: nowrap;
${ rtl( { left: 0 } ) };
@@ -207,6 +201,11 @@ export const ThumbWrapper = styled.span`
user-select: none;
width: ${ thumbSize }px;
border-radius: ${ CONFIG.radiusRound };
+ z-index: 3;
+
+ @media not ( prefers-reduced-motion ) {
+ transition: left ease 0.1s;
+ }
${ thumbColor };
${ rtl( { marginLeft: -10 } ) };
From 2331573dd954b50865071b56403c85b82c625568 Mon Sep 17 00:00:00 2001
From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com>
Date: Fri, 6 Dec 2024 14:32:22 +0000
Subject: [PATCH 12/23] Bump actions/cache from 4.1.2 to 4.2.0 in the
github-actions group (#67692)
Bumps the github-actions group with 1 update: [actions/cache](https://github.com/actions/cache).
Updates `actions/cache` from 4.1.2 to 4.2.0
- [Release notes](https://github.com/actions/cache/releases)
- [Changelog](https://github.com/actions/cache/blob/main/RELEASES.md)
- [Commits](https://github.com/actions/cache/compare/6849a6489940f00c2f30c0fb92c6274307ccb58a...1bd1e32a3bdc45362d1e726936510720a7c30a57)
---
updated-dependencies:
- dependency-name: actions/cache
dependency-type: direct:production
update-type: version-update:semver-minor
dependency-group: github-actions
...
Signed-off-by: dependabot[bot]
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: desrosj
---
.github/workflows/rnmobile-android-runner.yml | 4 ++--
.github/workflows/rnmobile-ios-runner.yml | 6 +++---
.github/workflows/unit-test.yml | 2 +-
3 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/.github/workflows/rnmobile-android-runner.yml b/.github/workflows/rnmobile-android-runner.yml
index f8ff0441a95b7..e4d9da813417e 100644
--- a/.github/workflows/rnmobile-android-runner.yml
+++ b/.github/workflows/rnmobile-android-runner.yml
@@ -37,7 +37,7 @@ jobs:
uses: ./.github/setup-node
- name: Restore tests setup cache
- uses: actions/cache@6849a6489940f00c2f30c0fb92c6274307ccb58a # v4.1.2
+ uses: actions/cache@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4.2.0
with:
path: |
~/.appium
@@ -52,7 +52,7 @@ jobs:
# AVD cache disabled as it caused emulator termination to hang indefinitely.
# https://github.com/ReactiveCircus/android-emulator-runner/issues/385
# - name: AVD cache
- # uses: actions/cache@6849a6489940f00c2f30c0fb92c6274307ccb58a # v4.1.2
+ # uses: actions/cache@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4.2.0
# id: avd-cache
# with:
# path: |
diff --git a/.github/workflows/rnmobile-ios-runner.yml b/.github/workflows/rnmobile-ios-runner.yml
index d28ee65c719e4..e1e7fd8c755c9 100644
--- a/.github/workflows/rnmobile-ios-runner.yml
+++ b/.github/workflows/rnmobile-ios-runner.yml
@@ -42,7 +42,7 @@ jobs:
uses: ./.github/setup-node
- name: Restore tests setup cache
- uses: actions/cache@6849a6489940f00c2f30c0fb92c6274307ccb58a # v4.1.2
+ uses: actions/cache@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4.2.0
with:
path: |
~/.appium
@@ -55,7 +55,7 @@ jobs:
run: find package-lock.json packages/react-native-editor/ios packages/react-native-aztec/ios packages/react-native-bridge/ios -type f -print0 | sort -z | xargs -0 shasum | tee ios-checksums.txt
- name: Restore build cache
- uses: actions/cache@6849a6489940f00c2f30c0fb92c6274307ccb58a # v4.1.2
+ uses: actions/cache@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4.2.0
with:
path: |
packages/react-native-editor/ios/build/GutenbergDemo/Build/Products/Release-iphonesimulator/GutenbergDemo.app
@@ -63,7 +63,7 @@ jobs:
key: ${{ runner.os }}-ios-build-${{ matrix.xcode }}-${{ matrix.device }}-${{ hashFiles('ios-checksums.txt') }}
- name: Restore pods cache
- uses: actions/cache@6849a6489940f00c2f30c0fb92c6274307ccb58a # v4.1.2
+ uses: actions/cache@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4.2.0
with:
path: |
packages/react-native-editor/ios/Pods
diff --git a/.github/workflows/unit-test.yml b/.github/workflows/unit-test.yml
index 46aa109c23e65..efc7ef76f8c64 100644
--- a/.github/workflows/unit-test.yml
+++ b/.github/workflows/unit-test.yml
@@ -296,7 +296,7 @@ jobs:
run: echo "date=$(/bin/date -u --date='last Mon' "+%F")" >> $GITHUB_OUTPUT
- name: Cache PHPCS scan cache
- uses: actions/cache@6849a6489940f00c2f30c0fb92c6274307ccb58a # v4.1.2
+ uses: actions/cache@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4.2.0
with:
path: .cache/phpcs.json
key: ${{ runner.os }}-date-${{ steps.get-date.outputs.date }}-phpcs-cache-${{ hashFiles('**/composer.json', 'phpcs.xml.dist') }}
From 00c32f498cf890edd9d334a96a1bc840a5a11920 Mon Sep 17 00:00:00 2001
From: Sarthak Nagoshe <83178197+sarthaknagoshe2002@users.noreply.github.com>
Date: Fri, 6 Dec 2024 20:05:37 +0530
Subject: [PATCH 13/23] Update pre-publish panel wording to accurately describe
the review process (#67328)
* Fix: Update pre-publish panel wording
* Fix: Remove redundancy from the wording and use 'can' instead of 'will be able to'
* Fix: shorten the message
* Fix: modify test snapshot & capitalize the first char
* Fix: rectify test snapshot
Co-authored-by: sarthaknagoshe2002
Co-authored-by: afercia
Co-authored-by: jasmussen
Co-authored-by: hanneslsm
---
.../editor/src/components/post-publish-panel/prepublish.js | 2 +-
.../post-publish-panel/test/__snapshots__/index.js.snap | 4 ++--
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/packages/editor/src/components/post-publish-panel/prepublish.js b/packages/editor/src/components/post-publish-panel/prepublish.js
index 193960b9cc834..e8d5c69b76930 100644
--- a/packages/editor/src/components/post-publish-panel/prepublish.js
+++ b/packages/editor/src/components/post-publish-panel/prepublish.js
@@ -75,7 +75,7 @@ function PostPublishPanelPrepublish( { children } ) {
if ( ! hasPublishAction ) {
prePublishTitle = __( 'Are you ready to submit for review?' );
prePublishBodyText = __(
- 'When you’re ready, submit your work for review, and an Editor will be able to approve it for you.'
+ 'Your work will be reviewed and then approved.'
);
} else if ( isBeingScheduled ) {
prePublishTitle = __( 'Are you ready to schedule?' );
diff --git a/packages/editor/src/components/post-publish-panel/test/__snapshots__/index.js.snap b/packages/editor/src/components/post-publish-panel/test/__snapshots__/index.js.snap
index b074159ac423d..9fb3d24cd2931 100644
--- a/packages/editor/src/components/post-publish-panel/test/__snapshots__/index.js.snap
+++ b/packages/editor/src/components/post-publish-panel/test/__snapshots__/index.js.snap
@@ -466,7 +466,7 @@ exports[`PostPublishPanel should render the pre-publish panel if post status is
- When you’re ready, submit your work for review, and an Editor will be able to approve it for you.
+ Your work will be reviewed and then approved.
- When you’re ready, submit your work for review, and an Editor will be able to approve it for you.
+ Your work will be reviewed and then approved.
Date: Fri, 6 Dec 2024 12:14:37 -0600
Subject: [PATCH 14/23] Fix useZoomOut inserter behavior (#67591)
* Add e2e tests to cover scenarios for useZoomOut with the Inserter
* Add controlled concept to useZoomOut hook
---------
Co-authored-by: George Mamadashvili
Co-authored-by: ajlende
---
.../block-editor/src/hooks/use-zoom-out.js | 64 +++-
test/e2e/specs/site-editor/preload.spec.js | 1 +
.../site-editor/site-editor-inserter.spec.js | 311 ++++++++++++++++--
3 files changed, 333 insertions(+), 43 deletions(-)
diff --git a/packages/block-editor/src/hooks/use-zoom-out.js b/packages/block-editor/src/hooks/use-zoom-out.js
index bcf5d9ff882f7..adcea8b605aeb 100644
--- a/packages/block-editor/src/hooks/use-zoom-out.js
+++ b/packages/block-editor/src/hooks/use-zoom-out.js
@@ -2,7 +2,7 @@
* WordPress dependencies
*/
import { useSelect, useDispatch } from '@wordpress/data';
-import { useEffect } from '@wordpress/element';
+import { useEffect, useRef } from '@wordpress/element';
/**
* Internal dependencies
@@ -12,32 +12,64 @@ import { unlock } from '../lock-unlock';
/**
* A hook used to set the editor mode to zoomed out mode, invoking the hook sets the mode.
+ * Concepts:
+ * - If we most recently changed the zoom level for them (in or out), we always resetZoomLevel() level when unmounting.
+ * - If the user most recently changed the zoom level (manually toggling), we do nothing when unmounting.
*
- * @param {boolean} zoomOut If we should enter into zoomOut mode or not
+ * @param {boolean} enabled If we should enter into zoomOut mode or not
*/
-export function useZoomOut( zoomOut = true ) {
+export function useZoomOut( enabled = true ) {
const { setZoomLevel, resetZoomLevel } = unlock(
useDispatch( blockEditorStore )
);
- const { isZoomOut } = unlock( useSelect( blockEditorStore ) );
+ /**
+ * We need access to both the value and the function. The value is to trigger a useEffect hook
+ * and the function is to check zoom out within another hook without triggering a re-render.
+ */
+ const { isZoomedOut, isZoomOut } = useSelect( ( select ) => {
+ const { isZoomOut: _isZoomOut } = unlock( select( blockEditorStore ) );
+ return {
+ isZoomedOut: _isZoomOut(),
+ isZoomOut: _isZoomOut,
+ };
+ }, [] );
+
+ const controlZoomLevelRef = useRef( false );
+ const isEnabledRef = useRef( enabled );
+
+ /**
+ * This hook tracks if the zoom state was changed manually by the user via clicking
+ * the zoom out button. We only want this to run when isZoomedOut changes, so we use
+ * a ref to track the enabled state.
+ */
useEffect( () => {
- const isZoomOutOnMount = isZoomOut();
+ // If the zoom state changed (isZoomOut) and it does not match the requested zoom
+ // state (zoomOut), then it means the user manually changed the zoom state while
+ // this hook was mounted, and we should no longer control the zoom state.
+ if ( isZoomedOut !== isEnabledRef.current ) {
+ controlZoomLevelRef.current = false;
+ }
+ }, [ isZoomedOut ] );
- return () => {
- if ( isZoomOutOnMount ) {
+ useEffect( () => {
+ isEnabledRef.current = enabled;
+
+ if ( enabled !== isZoomOut() ) {
+ controlZoomLevelRef.current = true;
+
+ if ( enabled ) {
setZoomLevel( 'auto-scaled' );
} else {
resetZoomLevel();
}
- };
- }, [] );
-
- useEffect( () => {
- if ( zoomOut ) {
- setZoomLevel( 'auto-scaled' );
- } else {
- resetZoomLevel();
}
- }, [ zoomOut, setZoomLevel, resetZoomLevel ] );
+
+ return () => {
+ // If we are controlling zoom level and are zoomed out, reset the zoom level.
+ if ( controlZoomLevelRef.current && isZoomOut() ) {
+ resetZoomLevel();
+ }
+ };
+ }, [ enabled, isZoomOut, resetZoomLevel, setZoomLevel ] );
}
diff --git a/test/e2e/specs/site-editor/preload.spec.js b/test/e2e/specs/site-editor/preload.spec.js
index 2cd61283fbd9e..e731e932e3052 100644
--- a/test/e2e/specs/site-editor/preload.spec.js
+++ b/test/e2e/specs/site-editor/preload.spec.js
@@ -6,6 +6,7 @@ const { test, expect } = require( '@wordpress/e2e-test-utils-playwright' );
test.describe( 'Preload', () => {
test.beforeAll( async ( { requestUtils } ) => {
await requestUtils.activateTheme( 'emptytheme' );
+ await requestUtils.resetPreferences();
} );
test.afterAll( async ( { requestUtils } ) => {
diff --git a/test/e2e/specs/site-editor/site-editor-inserter.spec.js b/test/e2e/specs/site-editor/site-editor-inserter.spec.js
index 04075cbedab30..a730367d841bf 100644
--- a/test/e2e/specs/site-editor/site-editor-inserter.spec.js
+++ b/test/e2e/specs/site-editor/site-editor-inserter.spec.js
@@ -5,8 +5,9 @@ const { test, expect } = require( '@wordpress/e2e-test-utils-playwright' );
test.describe( 'Site Editor Inserter', () => {
test.beforeAll( async ( { requestUtils } ) => {
+ // We need the theme to have a section root so zoom out is enabled
await Promise.all( [
- requestUtils.activateTheme( 'emptytheme' ),
+ requestUtils.activateTheme( 'twentytwentyfour' ),
requestUtils.deleteAllTemplates( 'wp_template' ),
requestUtils.deleteAllTemplates( 'wp_template_part' ),
] );
@@ -21,47 +22,303 @@ test.describe( 'Site Editor Inserter', () => {
await editor.canvas.locator( 'body' ).click();
} );
+ test.use( {
+ InserterUtils: async ( { editor, page }, use ) => {
+ await use( new InserterUtils( { editor, page } ) );
+ },
+ } );
+
+ // eslint-disable-next-line playwright/expect-expect
test( 'inserter toggle button should toggle global inserter', async ( {
- page,
+ InserterUtils,
} ) => {
- await page.click( 'role=button[name="Block Inserter"i]' );
-
- // Visibility check
- await expect(
- page.locator( 'role=searchbox[name="Search"i]' )
- ).toBeVisible();
- await page.click( 'role=button[name="Block Inserter"i]' );
- //Hidden State check
- await expect(
- page.locator( 'role=searchbox[name="Search"i]' )
- ).toBeHidden();
+ await InserterUtils.openBlockLibrary();
+ await InserterUtils.closeBlockLibrary();
} );
// A test for https://github.com/WordPress/gutenberg/issues/43090.
test( 'should close the inserter when clicking on the toggle button', async ( {
- page,
editor,
+ InserterUtils,
} ) => {
- const inserterButton = page.getByRole( 'button', {
- name: 'Block Inserter',
- exact: true,
- } );
- const blockLibrary = page.getByRole( 'region', {
- name: 'Block Library',
- } );
-
const beforeBlocks = await editor.getBlocks();
- await inserterButton.click();
- await blockLibrary.getByRole( 'tab', { name: 'Blocks' } ).click();
- await blockLibrary.getByRole( 'option', { name: 'Buttons' } ).click();
+ await InserterUtils.openBlockLibrary();
+ await InserterUtils.expectActiveTab( 'Blocks' );
+ await InserterUtils.blockLibrary
+ .getByRole( 'option', { name: 'Buttons' } )
+ .click();
await expect
.poll( editor.getBlocks )
.toMatchObject( [ ...beforeBlocks, { name: 'core/buttons' } ] );
- await inserterButton.click();
+ await InserterUtils.closeBlockLibrary();
+ } );
+
+ test.describe( 'Inserter Zoom Level UX', () => {
+ test.use( {
+ ZoomUtils: async ( { editor, page }, use ) => {
+ await use( new ZoomUtils( { editor, page } ) );
+ },
+ } );
+
+ test( 'should intialize correct active tab based on zoom level', async ( {
+ InserterUtils,
+ ZoomUtils,
+ } ) => {
+ await test.step( 'should open the inserter to blocks tab from default zoom level', async () => {
+ await InserterUtils.openBlockLibrary();
+ await InserterUtils.expectActiveTab( 'Blocks' );
+
+ // Zoom canvas should not be active
+ await expect( ZoomUtils.zoomCanvas ).toBeHidden();
+
+ await InserterUtils.closeBlockLibrary();
+
+ // Zoom canvas should not be active
+ await expect( ZoomUtils.zoomCanvas ).toBeHidden();
+ } );
+
+ await test.step( 'should open the inserter to patterns tab if zoomed out', async () => {
+ await ZoomUtils.enterZoomOut();
+ await InserterUtils.openBlockLibrary();
+ await InserterUtils.expectActiveTab( 'Patterns' );
+
+ // Zoom canvas should still be active
+ await expect( ZoomUtils.zoomCanvas ).toBeVisible();
+
+ await InserterUtils.closeBlockLibrary();
+
+ // We should still be in Zoom Out
+ await expect( ZoomUtils.zoomCanvas ).toBeVisible();
+ } );
+ } );
+
+ test( 'should set the correct zoom level when changing tabs', async ( {
+ InserterUtils,
+ ZoomUtils,
+ } ) => {
+ await InserterUtils.openBlockLibrary();
+ await InserterUtils.expectActiveTab( 'Blocks' );
+ await expect( ZoomUtils.zoomCanvas ).toBeHidden();
+
+ await test.step( 'should zoom out when activating patterns tab', async () => {
+ await InserterUtils.activateTab( 'Patterns' );
+ await expect( ZoomUtils.zoomCanvas ).toBeVisible();
+ } );
+
+ await test.step( 'should reset zoom level when activating blocks tab', async () => {
+ await InserterUtils.activateTab( 'Blocks' );
+ await expect( ZoomUtils.zoomCanvas ).toBeHidden();
+ } );
+
+ await test.step( 'should zoom out when activating media tab', async () => {
+ await InserterUtils.activateTab( 'Media' );
+ await expect( ZoomUtils.zoomCanvas ).toBeVisible();
+ } );
+ } );
+
+ test( 'should reset the zoom level when closing the inserter if we most recently changed the zoom level', async ( {
+ InserterUtils,
+ ZoomUtils,
+ } ) => {
+ await test.step( 'should reset zoom when closing from patterns tab', async () => {
+ await InserterUtils.openBlockLibrary();
+ await InserterUtils.expectActiveTab( 'Blocks' );
+ await expect( ZoomUtils.zoomCanvas ).toBeHidden();
+
+ await InserterUtils.activateTab( 'Patterns' );
+ await expect( ZoomUtils.zoomCanvas ).toBeVisible();
+
+ await InserterUtils.closeBlockLibrary();
+
+ // Zoom Level should be reset
+ await expect( ZoomUtils.zoomCanvas ).toBeHidden();
+ } );
+
+ await test.step( 'should preserve default zoom level when closing from blocks tab', async () => {
+ await InserterUtils.openBlockLibrary();
+ await InserterUtils.expectActiveTab( 'Blocks' );
+ await expect( ZoomUtils.zoomCanvas ).toBeHidden();
+
+ await InserterUtils.activateTab( 'Media' );
+ await expect( ZoomUtils.zoomCanvas ).toBeVisible();
+
+ await InserterUtils.activateTab( 'Blocks' );
+ await expect( ZoomUtils.zoomCanvas ).toBeHidden();
+
+ await InserterUtils.closeBlockLibrary();
+
+ // Zoom Level should stay at default level
+ await expect( ZoomUtils.zoomCanvas ).toBeHidden();
+ } );
+
+ await test.step( 'should preserve default zoom level when closing from blocks tab even if user manually toggled zoom level on previous tab', async () => {
+ await InserterUtils.openBlockLibrary();
+ await InserterUtils.expectActiveTab( 'Blocks' );
+ await expect( ZoomUtils.zoomCanvas ).toBeHidden();
+
+ await InserterUtils.activateTab( 'Media' );
+ await expect( ZoomUtils.zoomCanvas ).toBeVisible();
+
+ // Toggle zoom level manually
+ await ZoomUtils.exitZoomOut();
+
+ await InserterUtils.activateTab( 'Blocks' );
+ await expect( ZoomUtils.zoomCanvas ).toBeHidden();
+
+ await InserterUtils.closeBlockLibrary();
+
+ // Zoom Level should stay at default level
+ await expect( ZoomUtils.zoomCanvas ).toBeHidden();
+ } );
- await expect( blockLibrary ).toBeHidden();
+ await test.step( 'should preserve default zoom level when closing from blocks tab even if user manually toggled zoom level on previous tab twice', async () => {
+ // Open inserter
+ await InserterUtils.openBlockLibrary();
+ await InserterUtils.expectActiveTab( 'Blocks' );
+ await expect( ZoomUtils.zoomCanvas ).toBeHidden();
+
+ await InserterUtils.activateTab( 'Media' );
+ await expect( ZoomUtils.zoomCanvas ).toBeVisible();
+
+ // Toggle zoom level manually twice
+ await ZoomUtils.exitZoomOut();
+ await ZoomUtils.enterZoomOut();
+
+ await InserterUtils.activateTab( 'Blocks' );
+ await expect( ZoomUtils.zoomCanvas ).toBeHidden();
+
+ await InserterUtils.closeBlockLibrary();
+
+ // Zoom Level should stay at default level
+ await expect( ZoomUtils.zoomCanvas ).toBeHidden();
+ } );
+ } );
+
+ test( 'should keep the zoom level manually set by the user if the user most recently set the zoom level', async ( {
+ InserterUtils,
+ ZoomUtils,
+ } ) => {
+ await test.step( 'should respect manual zoom level set when closing from patterns tab', async () => {
+ await InserterUtils.openBlockLibrary();
+ await InserterUtils.expectActiveTab( 'Blocks' );
+ await expect( ZoomUtils.zoomCanvas ).toBeHidden();
+
+ await InserterUtils.activateTab( 'Patterns' );
+ await expect( ZoomUtils.zoomCanvas ).toBeVisible();
+
+ await ZoomUtils.exitZoomOut();
+
+ await InserterUtils.closeBlockLibrary();
+
+ // Zoom Level should stay reset
+ await expect( ZoomUtils.zoomCanvas ).toBeHidden();
+ } );
+
+ await test.step( 'should respect manual zoom level set when closing from patterns tab when toggled twice', async () => {
+ await InserterUtils.openBlockLibrary();
+ await InserterUtils.expectActiveTab( 'Blocks' );
+ await expect( ZoomUtils.zoomCanvas ).toBeHidden();
+
+ await InserterUtils.activateTab( 'Patterns' );
+ await expect( ZoomUtils.zoomCanvas ).toBeVisible();
+
+ await ZoomUtils.exitZoomOut();
+
+ await ZoomUtils.enterZoomOut();
+
+ await InserterUtils.closeBlockLibrary();
+
+ // Should stay zoomed out since it was manually engaged
+ await expect( ZoomUtils.zoomCanvas ).toBeVisible();
+
+ // Reset test
+ await ZoomUtils.exitZoomOut();
+ } );
+
+ await test.step( 'should not reset zoom level if zoom level manually changed from blocks tab', async () => {
+ await InserterUtils.openBlockLibrary();
+ await expect( InserterUtils.blockLibrary ).toBeVisible();
+
+ await InserterUtils.expectActiveTab( 'Blocks' );
+ await expect( ZoomUtils.zoomCanvas ).toBeHidden();
+
+ await ZoomUtils.enterZoomOut();
+
+ await InserterUtils.closeBlockLibrary();
+
+ // Should stay zoomed out since it was manually engaged
+ await expect( ZoomUtils.zoomCanvas ).toBeVisible();
+ } );
+ } );
} );
} );
+
+class InserterUtils {
+ constructor( { editor, page } ) {
+ this.editor = editor;
+ this.page = page;
+ this.blockLibrary = this.page.getByRole( 'region', {
+ name: 'Block Library',
+ } );
+ this.inserterButton = this.page.getByRole( 'button', {
+ name: 'Block Inserter',
+ exact: true,
+ } );
+ }
+
+ // Manually naming as open and close these makes it clearer when reading
+ // through the test instead of using a toggle method with a boolean
+ async openBlockLibrary() {
+ await this.inserterButton.click();
+ await expect( this.blockLibrary ).toBeVisible();
+ }
+
+ async closeBlockLibrary() {
+ await this.inserterButton.click();
+ await expect( this.blockLibrary ).toBeHidden();
+ }
+
+ getBlockLibraryTab( name ) {
+ return this.page.getByRole( 'tab', { name } );
+ }
+
+ async expectActiveTab( name ) {
+ await expect( this.getBlockLibraryTab( name ) ).toHaveAttribute(
+ 'aria-selected',
+ 'true'
+ );
+ }
+
+ async activateTab( name ) {
+ await this.getBlockLibraryTab( name ).click();
+ // For brevity, adding this check here. It should always be done after the tab is clicked
+ await this.expectActiveTab( name );
+ }
+}
+
+class ZoomUtils {
+ constructor( { editor, page } ) {
+ this.editor = editor;
+ this.page = page;
+ this.zoomCanvas = this.page.locator( '.is-zoomed-out' );
+ this.zoomButton = this.page.getByRole( 'button', {
+ name: 'Zoom Out',
+ exact: true,
+ } );
+ }
+
+ // Manually naming as enter and exit these makes it clearer when reading
+ // through the test instead of using a toggle method with a boolean
+ async enterZoomOut() {
+ await this.zoomButton.click();
+ await expect( this.zoomCanvas ).toBeVisible();
+ }
+
+ async exitZoomOut() {
+ await this.zoomButton.click();
+ await expect( this.zoomCanvas ).toBeHidden();
+ }
+}
From 65193ea7a810c862697a6910394ad2294402dea5 Mon Sep 17 00:00:00 2001
From: Ramon
Date: Sat, 7 Dec 2024 10:38:42 +1100
Subject: [PATCH 15/23] Site Editor: remove default page slug (#67673)
Co-authored-by: ramonjd
Co-authored-by: t-hamano
Co-authored-by: youknowriad
Co-authored-by: carolinan
Co-authored-by: benazeer-ben
Co-authored-by: annezazu
---
packages/edit-site/src/components/add-new-post/index.js | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/packages/edit-site/src/components/add-new-post/index.js b/packages/edit-site/src/components/add-new-post/index.js
index 04e286e3967a4..a30f5995aab6f 100644
--- a/packages/edit-site/src/components/add-new-post/index.js
+++ b/packages/edit-site/src/components/add-new-post/index.js
@@ -45,7 +45,7 @@ export default function AddNewPostModal( { postType, onSave, onClose } ) {
{
status: 'draft',
title,
- slug: title || __( 'No title' ),
+ slug: title ?? undefined,
content:
!! postTypeObject.template &&
postTypeObject.template.length
From 96ceed1e91e8de6452cb20642dfac3735639d13d Mon Sep 17 00:00:00 2001
From: Aki Hamano <54422211+t-hamano@users.noreply.github.com>
Date: Sat, 7 Dec 2024 12:29:59 +0900
Subject: [PATCH 16/23] Global Styles Preview: Don't use iframe component
(#67682)
Co-authored-by: t-hamano
Co-authored-by: ramonjd
---
.../global-styles/preview-colors.js | 6 +--
.../global-styles/preview-styles.js | 6 +--
.../global-styles/preview-typography.js | 6 +--
.../{preview-iframe.js => preview-wrapper.js} | 44 ++++---------------
.../src/components/global-styles/style.scss | 6 +--
.../global-styles/typography-example.js | 13 +++++-
.../content.js | 42 +++---------------
7 files changed, 38 insertions(+), 85 deletions(-)
rename packages/edit-site/src/components/global-styles/{preview-iframe.js => preview-wrapper.js} (73%)
diff --git a/packages/edit-site/src/components/global-styles/preview-colors.js b/packages/edit-site/src/components/global-styles/preview-colors.js
index 8c1008330ec06..a7e6563748ca0 100644
--- a/packages/edit-site/src/components/global-styles/preview-colors.js
+++ b/packages/edit-site/src/components/global-styles/preview-colors.js
@@ -10,7 +10,7 @@ import {
* Internal dependencies
*/
import PresetColors from './preset-colors';
-import PreviewIframe from './preview-iframe';
+import PreviewWrapper from './preview-wrapper';
const firstFrameVariants = {
start: {
@@ -25,7 +25,7 @@ const firstFrameVariants = {
const StylesPreviewColors = ( { label, isFocused, withHoverView } ) => {
return (
- {
) }
-
+
);
};
diff --git a/packages/edit-site/src/components/global-styles/preview-styles.js b/packages/edit-site/src/components/global-styles/preview-styles.js
index dff1ef5a6f42b..f392e99ae951e 100644
--- a/packages/edit-site/src/components/global-styles/preview-styles.js
+++ b/packages/edit-site/src/components/global-styles/preview-styles.js
@@ -15,7 +15,7 @@ import { unlock } from '../../lock-unlock';
import { useStylesPreviewColors } from './hooks';
import TypographyExample from './typography-example';
import HighlightedColors from './highlighted-colors';
-import PreviewIframe from './preview-iframe';
+import PreviewWrapper from './preview-wrapper';
const { useGlobalStyle } = unlock( blockEditorPrivateApis );
@@ -67,7 +67,7 @@ const PreviewStyles = ( { label, isFocused, withHoverView, variation } ) => {
const { paletteColors } = useStylesPreviewColors();
return (
- {
) }
-
+
);
};
diff --git a/packages/edit-site/src/components/global-styles/preview-typography.js b/packages/edit-site/src/components/global-styles/preview-typography.js
index 26ae13eaa0908..686ebd1e6f065 100644
--- a/packages/edit-site/src/components/global-styles/preview-typography.js
+++ b/packages/edit-site/src/components/global-styles/preview-typography.js
@@ -7,11 +7,11 @@ import { __experimentalHStack as HStack } from '@wordpress/components';
* Internal dependencies
*/
import TypographyExample from './typography-example';
-import PreviewIframe from './preview-iframe';
+import PreviewWrapper from './preview-wrapper';
const StylesPreviewTypography = ( { variation, isFocused, withHoverView } ) => {
return (
- {
/>
) }
-
+
);
};
diff --git a/packages/edit-site/src/components/global-styles/preview-iframe.js b/packages/edit-site/src/components/global-styles/preview-wrapper.js
similarity index 73%
rename from packages/edit-site/src/components/global-styles/preview-iframe.js
rename to packages/edit-site/src/components/global-styles/preview-wrapper.js
index e830accf6d939..b3c83bad69d84 100644
--- a/packages/edit-site/src/components/global-styles/preview-iframe.js
+++ b/packages/edit-site/src/components/global-styles/preview-wrapper.js
@@ -1,27 +1,21 @@
/**
* WordPress dependencies
*/
-import {
- __unstableIframe as Iframe,
- __unstableEditorStyles as EditorStyles,
- privateApis as blockEditorPrivateApis,
-} from '@wordpress/block-editor';
+import { privateApis as blockEditorPrivateApis } from '@wordpress/block-editor';
import { __unstableMotion as motion } from '@wordpress/components';
import {
useThrottle,
useReducedMotion,
useResizeObserver,
} from '@wordpress/compose';
-import { useLayoutEffect, useState, useMemo } from '@wordpress/element';
+import { useLayoutEffect, useState } from '@wordpress/element';
/**
* Internal dependencies
*/
import { unlock } from '../../lock-unlock';
-const { useGlobalStyle, useGlobalStylesOutput } = unlock(
- blockEditorPrivateApis
-);
+const { useGlobalStyle } = unlock( blockEditorPrivateApis );
const normalizedWidth = 248;
const normalizedHeight = 152;
@@ -33,7 +27,7 @@ const THROTTLE_OPTIONS = {
trailing: true,
};
-export default function PreviewIframe( {
+export default function PreviewWrapper( {
children,
label,
isFocused,
@@ -41,7 +35,6 @@ export default function PreviewIframe( {
} ) {
const [ backgroundColor = 'white' ] = useGlobalStyle( 'color.background' );
const [ gradientValue ] = useGlobalStyle( 'color.gradient' );
- const [ styles ] = useGlobalStylesOutput();
const disableMotion = useReducedMotion();
const [ isHovered, setIsHovered ] = useState( false );
const [ containerResizeListener, { width } ] = useResizeObserver();
@@ -54,7 +47,7 @@ export default function PreviewIframe( {
THROTTLE_OPTIONS
);
- // Must use useLayoutEffect to avoid a flash of the iframe at the wrong
+ // Must use useLayoutEffect to avoid a flash of the container at the wrong
// size before the width is set.
useLayoutEffect( () => {
if ( width ) {
@@ -62,7 +55,7 @@ export default function PreviewIframe( {
}
}, [ width, setThrottledWidth ] );
- // Must use useLayoutEffect to avoid a flash of the iframe at the wrong
+ // Must use useLayoutEffect to avoid a flash of the container at the wrong
// size before the width is set.
useLayoutEffect( () => {
const newRatio = throttledWidth ? throttledWidth / normalizedWidth : 1;
@@ -89,24 +82,6 @@ export default function PreviewIframe( {
*/
const ratio = ratioState ? ratioState : fallbackRatio;
- /*
- * Reset leaked styles from WP common.css and remove main content layout padding and border.
- * Add pointer cursor to the body to indicate the iframe is interactive,
- * similar to Typography variation previews.
- */
- const editorStyles = useMemo( () => {
- if ( styles ) {
- return [
- ...styles,
- {
- css: 'html{overflow:hidden}body{min-width: 0;padding: 0;border: none;cursor: pointer;}',
- isGlobalStyles: true,
- },
- ];
- }
-
- return styles;
- }, [ styles ] );
const isReady = !! width;
return (
@@ -115,8 +90,8 @@ export default function PreviewIframe( {
{ containerResizeListener }
{ isReady && (
-
+
) }
>
);
diff --git a/packages/edit-site/src/components/global-styles/style.scss b/packages/edit-site/src/components/global-styles/style.scss
index 4674b5e5fc3ca..11dbae7bc66b1 100644
--- a/packages/edit-site/src/components/global-styles/style.scss
+++ b/packages/edit-site/src/components/global-styles/style.scss
@@ -6,7 +6,7 @@
cursor: pointer;
}
-.edit-site-global-styles-preview__iframe {
+.edit-site-global-styles-preview__wrapper {
max-width: 100%;
display: block;
width: 100%;
@@ -230,10 +230,6 @@
// The {&} is a workaround for the specificity of the Card component.
{&},
{&} .edit-site-global-styles-screen-root__active-style-tile-preview {
- box-shadow: none;
border-radius: $radius-small;
- .block-editor-iframe__container {
- border: 1px solid $gray-200;
- }
}
}
diff --git a/packages/edit-site/src/components/global-styles/typography-example.js b/packages/edit-site/src/components/global-styles/typography-example.js
index a491ca57bf5be..9c0a4e0e1cb13 100644
--- a/packages/edit-site/src/components/global-styles/typography-example.js
+++ b/packages/edit-site/src/components/global-styles/typography-example.js
@@ -14,7 +14,9 @@ import { unlock } from '../../lock-unlock';
import { getFamilyPreviewStyle } from './font-library-modal/utils/preview-styles';
import { getFontFamilies } from './utils';
-const { GlobalStylesContext } = unlock( blockEditorPrivateApis );
+const { useGlobalStyle, GlobalStylesContext } = unlock(
+ blockEditorPrivateApis
+);
const { mergeBaseAndUserConfigs } = unlock( editorPrivateApis );
export default function PreviewTypography( { fontSize, variation } ) {
@@ -23,6 +25,9 @@ export default function PreviewTypography( { fontSize, variation } ) {
if ( variation ) {
config = mergeBaseAndUserConfigs( base, variation );
}
+
+ const [ textColor ] = useGlobalStyle( 'color.text' );
+
const [ bodyFontFamilies, headingFontFamilies ] = getFontFamilies( config );
const bodyPreviewStyle = bodyFontFamilies
? getFamilyPreviewStyle( bodyFontFamilies )
@@ -31,6 +36,11 @@ export default function PreviewTypography( { fontSize, variation } ) {
? getFamilyPreviewStyle( headingFontFamilies )
: {};
+ if ( textColor ) {
+ bodyPreviewStyle.color = textColor;
+ headingPreviewStyle.color = textColor;
+ }
+
if ( fontSize ) {
bodyPreviewStyle.fontSize = fontSize;
headingPreviewStyle.fontSize = fontSize;
@@ -52,6 +62,7 @@ export default function PreviewTypography( { fontSize, variation } ) {
} }
style={ {
textAlign: 'center',
+ lineHeight: 1,
} }
>
diff --git a/packages/edit-site/src/components/sidebar-navigation-screen-global-styles/content.js b/packages/edit-site/src/components/sidebar-navigation-screen-global-styles/content.js
index 986238697f734..ce8cd32aa009c 100644
--- a/packages/edit-site/src/components/sidebar-navigation-screen-global-styles/content.js
+++ b/packages/edit-site/src/components/sidebar-navigation-screen-global-styles/content.js
@@ -2,54 +2,26 @@
* WordPress dependencies
*/
import { __ } from '@wordpress/i18n';
-import { useSelect } from '@wordpress/data';
import { __experimentalVStack as VStack } from '@wordpress/components';
-import { BlockEditorProvider } from '@wordpress/block-editor';
/**
* Internal dependencies
*/
import StyleVariationsContainer from '../global-styles/style-variations-container';
-import { unlock } from '../../lock-unlock';
-import { store as editSiteStore } from '../../store';
import ColorVariations from '../global-styles/variations/variations-color';
import TypographyVariations from '../global-styles/variations/variations-typography';
-const noop = () => {};
-
export default function SidebarNavigationScreenGlobalStylesContent() {
- const { storedSettings } = useSelect( ( select ) => {
- const { getSettings } = unlock( select( editSiteStore ) );
-
- return {
- storedSettings: getSettings(),
- };
- }, [] );
-
const gap = 3;
- // Wrap in a BlockEditorProvider to ensure that the Iframe's dependencies are
- // loaded. This is necessary because the Iframe component waits until
- // the block editor store's `__internalIsInitialized` is true before
- // rendering the iframe. Without this, the iframe previews will not render
- // in mobile viewport sizes, where the editor canvas is hidden.
return (
-
-
-
-
-
-
-
+
+
+
+
);
}
From 959bb6b006a8e3deecff9aad4e07658878029c26 Mon Sep 17 00:00:00 2001
From: Sarthak Nagoshe <83178197+sarthaknagoshe2002@users.noreply.github.com>
Date: Sat, 7 Dec 2024 09:23:09 +0530
Subject: [PATCH 17/23] Simplify description and option names in the Lock modal
dialog (#67437)
* Refactor Lock modal dialog for improved clarity and simplicity
* Fix: modify the e2e test cases
* Fix: shorten the text & make it feel more specific
Co-authored-by: sarthaknagoshe2002
Co-authored-by: t-hamano
Co-authored-by: afercia
Co-authored-by: mtias
---
.../block-editor/src/components/block-lock/modal.js | 10 ++++------
test/e2e/specs/editor/blocks/columns.spec.js | 2 +-
test/e2e/specs/editor/various/block-locking.spec.js | 4 ++--
test/e2e/specs/editor/various/block-switcher.spec.js | 2 +-
4 files changed, 8 insertions(+), 10 deletions(-)
diff --git a/packages/block-editor/src/components/block-lock/modal.js b/packages/block-editor/src/components/block-lock/modal.js
index 3be23f6adde14..df267e97165e3 100644
--- a/packages/block-editor/src/components/block-lock/modal.js
+++ b/packages/block-editor/src/components/block-lock/modal.js
@@ -99,9 +99,7 @@ export default function BlockLockModal( { clientId, onClose } ) {
>