From 67f5afbf1ca0f0c50194196e6f9580f6bc6e9ea2 Mon Sep 17 00:00:00 2001 From: Luigi Teschio Date: Tue, 6 Jan 2026 11:26:35 +0100 Subject: [PATCH 01/31] migrate EditorSnackbar and EditorNotices components to notice package --- .../data-basics/5-adding-a-delete-button.md | 14 ++--- package-lock.json | 5 +- packages/boot/package.json | 1 + packages/boot/src/components/root/index.tsx | 4 +- .../boot/src/components/root/single-page.tsx | 4 +- packages/boot/src/style.scss | 2 +- .../edit-post/src/components/layout/index.js | 5 +- .../src/components/layout/style.scss | 4 +- .../edit-site/src/components/layout/index.js | 5 +- .../src/components/layout/style.scss | 2 +- .../src/components/editor-interface/index.js | 19 +++++- .../components/editor-interface/style.scss | 8 +++ .../src/components/editor-notices/index.js | 42 ++++--------- .../src/components/editor-snackbars/index.js | 27 +++----- .../editor/src/components/header/style.scss | 2 +- packages/notices/package.json | 4 +- .../components/notices-default-list/index.tsx | 63 +++++++++++++++++++ .../notices-default-list/style.scss | 20 ++++++ .../notices-snackbar-list/index.tsx | 43 +++++++++++++ packages/notices/src/index.js | 2 + 20 files changed, 201 insertions(+), 75 deletions(-) create mode 100644 packages/notices/src/components/notices-default-list/index.tsx create mode 100644 packages/notices/src/components/notices-default-list/style.scss create mode 100644 packages/notices/src/components/notices-snackbar-list/index.tsx diff --git a/docs/how-to-guides/data-basics/5-adding-a-delete-button.md b/docs/how-to-guides/data-basics/5-adding-a-delete-button.md index e0a0b0d1e93370..5eea75664567f2 100644 --- a/docs/how-to-guides/data-basics/5-adding-a-delete-button.md +++ b/docs/how-to-guides/data-basics/5-adding-a-delete-button.md @@ -7,7 +7,7 @@ Here's a glimpse of what we're going to build: ![](https://raw.githubusercontent.com/WordPress/gutenberg/HEAD/docs/how-to-guides/data-basics/media/delete-button/delete-button.png) -### Step 1: Add a _Delete_ button +### Step 1: Add a *Delete* button Let's start by creating the `DeletePageButton` component and updating the user interface of our `PagesList` component: @@ -94,7 +94,7 @@ const DeletePageButton = ({ pageId }) => { ### Step 3: Add visual feedback -It may take a few moments for the REST API request to finish after clicking the _Delete_ button. Let's communicate that with a `` component similarly to what we did in the previous parts of this tutorial. +It may take a few moments for the REST API request to finish after clicking the *Delete* button. Let's communicate that with a `` component similarly to what we did in the previous parts of this tutorial. We'll need the `isDeletingEntityRecord` selector for that. It is similar to the `isSavingEntityRecord` selector we've already seen in [part 3](/docs/how-to-guides/data-basics/3-building-an-edit-form.md): it returns `true` or `false` and never issues any HTTP requests: @@ -193,15 +193,15 @@ Let's create our own `Notifications` components: ```js import { SnackbarList } from '@wordpress/components'; -import { store as noticesStore } from '@wordpress/notices'; +import { store as noticesStore, NoticesSnackbarList } from '@wordpress/notices'; function Notifications() { const notices = []; // We'll come back here in a second! return ( - ); } @@ -226,7 +226,7 @@ function Notifications() { return ( ); @@ -355,7 +355,7 @@ function SnackbarNotices() { return ( ); diff --git a/package-lock.json b/package-lock.json index e76aa29a106962..392b239a865ff9 100644 --- a/package-lock.json +++ b/package-lock.json @@ -52715,6 +52715,7 @@ "@wordpress/keyboard-shortcuts": "file:../keyboard-shortcuts", "@wordpress/keycodes": "file:../keycodes", "@wordpress/lazy-editor": "file:../lazy-editor", + "@wordpress/notices": "file:../notices", "@wordpress/primitives": "file:../primitives", "@wordpress/private-apis": "file:../private-apis", "@wordpress/route": "file:../route", @@ -54136,7 +54137,9 @@ "license": "GPL-2.0-or-later", "dependencies": { "@wordpress/a11y": "file:../a11y", - "@wordpress/data": "file:../data" + "@wordpress/components": "file:../components", + "@wordpress/data": "file:../data", + "clsx": "^2.1.1" }, "devDependencies": { "deep-freeze": "0.0.1" diff --git a/packages/boot/package.json b/packages/boot/package.json index 722450e0fcbf49..c6c881149238a1 100644 --- a/packages/boot/package.json +++ b/packages/boot/package.json @@ -57,6 +57,7 @@ "@wordpress/keyboard-shortcuts": "file:../keyboard-shortcuts", "@wordpress/keycodes": "file:../keycodes", "@wordpress/lazy-editor": "file:../lazy-editor", + "@wordpress/notices": "file:../notices", "@wordpress/primitives": "file:../primitives", "@wordpress/private-apis": "file:../private-apis", "@wordpress/route": "file:../route", diff --git a/packages/boot/src/components/root/index.tsx b/packages/boot/src/components/root/index.tsx index 94ffb1e0bf0b38..fc45be11c570a4 100644 --- a/packages/boot/src/components/root/index.tsx +++ b/packages/boot/src/components/root/index.tsx @@ -7,7 +7,7 @@ import clsx from 'clsx'; * WordPress dependencies */ import { privateApis as routePrivateApis } from '@wordpress/route'; -import { EditorSnackbars } from '@wordpress/editor'; +import { NoticesSnackbarList } from '@wordpress/notices'; import { useViewportMatch, useReducedMotion } from '@wordpress/compose'; import { __unstableMotion as motion, @@ -68,7 +68,7 @@ export default function Root() { } ) } > - + { isMobileViewport && ( + + + + + ); +} +``` + ## Contributing to this package This is an individual package that's part of the Gutenberg project. The project is organized as a monorepo. It's made up of multiple self-contained software packages, each with a specific purpose. The packages in this monorepo are published to [npm](https://www.npmjs.com/) and used by [WordPress](https://make.wordpress.org/core/) as well as other software projects. From f81b353b61e2b0914a4af891c9b68e45dc7e2dca Mon Sep 17 00:00:00 2001 From: Luigi Teschio Date: Wed, 18 Feb 2026 10:00:00 +0100 Subject: [PATCH 28/31] improve code --- .../src/components/editor-interface/index.js | 27 ++++++++----------- 1 file changed, 11 insertions(+), 16 deletions(-) diff --git a/packages/editor/src/components/editor-interface/index.js b/packages/editor/src/components/editor-interface/index.js index 153babfb5da6d0..f6ab27d02652c2 100644 --- a/packages/editor/src/components/editor-interface/index.js +++ b/packages/editor/src/components/editor-interface/index.js @@ -46,6 +46,15 @@ const interfaceLabels = { footer: __( 'Editor footer' ), }; +const Notices = () => ( + + + +); + export default function EditorInterface( { className, children, @@ -182,14 +191,7 @@ export default function EditorInterface( { /> ) } - editorNotices={ - - - - } + editorNotices={ } secondarySidebar={ ! isAttachment && ! isPreviewMode && @@ -203,14 +205,7 @@ export default function EditorInterface( { } content={ <> - { ! isDistractionFree && ! isPreviewMode && ( - - - - ) } + { ! isDistractionFree && ! isPreviewMode && } { shouldShowMediaEditor && ( ) } From 678d0c669c7e038d3d4e020720d637892418c120 Mon Sep 17 00:00:00 2001 From: Luigi Teschio Date: Wed, 18 Feb 2026 10:59:15 +0100 Subject: [PATCH 29/31] pass context --- .../components/media-upload-modal/index.tsx | 33 ++++--------------- .../src/components/inline-notices/index.tsx | 8 +++-- .../src/components/snackbar-notices/index.tsx | 12 ++++--- 3 files changed, 20 insertions(+), 33 deletions(-) diff --git a/packages/media-utils/src/components/media-upload-modal/index.tsx b/packages/media-utils/src/components/media-upload-modal/index.tsx index 5a8953a38f8176..6950c92832c039 100644 --- a/packages/media-utils/src/components/media-upload-modal/index.tsx +++ b/packages/media-utils/src/components/media-upload-modal/index.tsx @@ -7,14 +7,8 @@ import { privateApis as coreDataPrivateApis, store as coreStore, } from '@wordpress/core-data'; -import { resolveSelect, useDispatch, useSelect } from '@wordpress/data'; -import { - Modal, - DropZone, - FormFileUpload, - Button, - SnackbarList, -} from '@wordpress/components'; +import { resolveSelect, useDispatch } from '@wordpress/data'; +import { Modal, DropZone, FormFileUpload, Button } from '@wordpress/components'; import { upload as uploadIcon } from '@wordpress/icons'; import { DataViewsPicker } from '@wordpress/dataviews'; import type { View, Field, ActionButton } from '@wordpress/dataviews'; @@ -32,7 +26,7 @@ import { mediaThumbnailField, mimeTypeField, } from '@wordpress/media-fields'; -import { store as noticesStore } from '@wordpress/notices'; +import { store as noticesStore, SnackbarNotices } from '@wordpress/notices'; import { isBlobURL } from '@wordpress/blob'; /** @@ -174,21 +168,11 @@ export function MediaUploadModal( { : [ String( value ) ]; } ); - const { - createSuccessNotice, - createErrorNotice, - createInfoNotice, - removeNotice, - } = useDispatch( noticesStore ); + const { createSuccessNotice, createErrorNotice, createInfoNotice } = + useDispatch( noticesStore ); // @ts-expect-error - invalidateResolution is not in the typed actions but is available at runtime const { invalidateResolution } = useDispatch( coreStore ); - // Get notices for this modal context - const notices = useSelect( - ( select ) => select( noticesStore ).getNotices( NOTICES_CONTEXT ), - [] - ); - // DataViews configuration - allow view updates const [ view, setView ] = useState< View >( () => ( { type: LAYOUT_PICKER_GRID, @@ -581,12 +565,9 @@ export function MediaUploadModal( { searchLabel={ searchLabel } itemListLabel={ __( 'Media items' ) } /> - type === 'snackbar' - ) } + removeNotice( id, NOTICES_CONTEXT ) } + context={ NOTICES_CONTEXT } /> ); diff --git a/packages/notices/src/components/inline-notices/index.tsx b/packages/notices/src/components/inline-notices/index.tsx index 02402c4fb049ed..0c6392fdbf913a 100644 --- a/packages/notices/src/components/inline-notices/index.tsx +++ b/packages/notices/src/components/inline-notices/index.tsx @@ -20,16 +20,18 @@ type InlineNoticesProps = { children?: ReactNode; pinnedNoticesClassName?: string; dismissibleNoticesClassName?: string; + context?: string; }; export default function InlineNotices( { children, pinnedNoticesClassName, dismissibleNoticesClassName, + context, }: InlineNoticesProps ) { const notices = useSelect( - ( select ) => select( noticesStore ).getNotices(), - [] + ( select ) => select( noticesStore ).getNotices( context ), + [ context ] ); const { removeNotice } = useDispatch( noticesStore ); const dismissibleNotices = notices.filter( @@ -54,7 +56,7 @@ export default function InlineNotices( { 'components-notices__dismissible', dismissibleNoticesClassName ) } - onRemove={ removeNotice } + onRemove={ ( id ) => removeNotice( id, context ) } > { children } diff --git a/packages/notices/src/components/snackbar-notices/index.tsx b/packages/notices/src/components/snackbar-notices/index.tsx index ba489f62f31439..1a5b92a89e8e25 100644 --- a/packages/notices/src/components/snackbar-notices/index.tsx +++ b/packages/notices/src/components/snackbar-notices/index.tsx @@ -19,12 +19,16 @@ const MAX_VISIBLE_NOTICES = -3; type SnackbarNoticesProps = { className?: string; + context?: string; }; -export default function SnackbarNotices( { className }: SnackbarNoticesProps ) { +export default function SnackbarNotices( { + className, + context, +}: SnackbarNoticesProps ) { const notices = useSelect( - ( select ) => select( noticesStore ).getNotices(), - [] + ( select ) => select( noticesStore ).getNotices( context ), + [ context ] ); const { removeNotice } = useDispatch( noticesStore ); const snackbarNotices = notices @@ -35,7 +39,7 @@ export default function SnackbarNotices( { className }: SnackbarNoticesProps ) { removeNotice( id, context ) } /> ); } From 3db153a9647c9adad46c42520284afcffd4bc66c Mon Sep 17 00:00:00 2001 From: Luigi Teschio Date: Wed, 18 Feb 2026 11:02:23 +0100 Subject: [PATCH 30/31] fix CSS --- packages/edit-post/src/components/layout/style.scss | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/edit-post/src/components/layout/style.scss b/packages/edit-post/src/components/layout/style.scss index 2e5e0442d58a5c..a3a5ee438ff339 100644 --- a/packages/edit-post/src/components/layout/style.scss +++ b/packages/edit-post/src/components/layout/style.scss @@ -129,4 +129,4 @@ padding-right: 24px; } -@include editor-left(".edit-post-layout__snackbar"); +@include editor-left(".edit-post-layout .edit-post-layout__snackbar"); From 6f7acf6e3ba090e6e52ad67d81b01c372a1e3b54 Mon Sep 17 00:00:00 2001 From: Luigi Teschio Date: Wed, 18 Feb 2026 14:12:39 +0100 Subject: [PATCH 31/31] fix style for media upload modal --- .../src/components/media-upload-modal/style.scss | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/packages/media-utils/src/components/media-upload-modal/style.scss b/packages/media-utils/src/components/media-upload-modal/style.scss index 35881ccb4a0f29..5bccb3611e6a94 100644 --- a/packages/media-utils/src/components/media-upload-modal/style.scss +++ b/packages/media-utils/src/components/media-upload-modal/style.scss @@ -1,4 +1,5 @@ @use "@wordpress/base-styles/variables" as *; +@use "@wordpress/base-styles/mixins" as *; .media-upload-modal { .components-modal__header { @@ -22,10 +23,6 @@ } .media-upload-modal__snackbar { - position: absolute; - left: 0; - bottom: 16px; - padding-left: 16px; - padding-right: 16px; + @include snackbar-container(); } }