diff --git a/docs/reference-guides/data/data-core-edit-widgets.md b/docs/reference-guides/data/data-core-edit-widgets.md index 2dde89bf69ad7..e62828dedd3b2 100644 --- a/docs/reference-guides/data/data-core-edit-widgets.md +++ b/docs/reference-guides/data/data-core-edit-widgets.md @@ -208,30 +208,24 @@ _Returns_ ### setIsInserterOpened +> **Deprecated** + Returns an action object used to open/close the inserter. _Parameters_ -- _value_ `boolean|Object`: Whether the inserter should be opened (true) or closed (false). To specify an insertion point, use an object. -- _value.rootClientId_ `string`: The root client ID to insert at. -- _value.insertionIndex_ `number`: The index to insert at. - -_Returns_ - -- `Object`: Action object. +- _value_ `boolean|Object`: Whether the inserter should be opened (true) or closed (false). ### setIsListViewOpened +> **Deprecated** + Returns an action object used to open/close the list view. _Parameters_ - _isOpen_ `boolean`: A boolean representing whether the list view should be opened or closed. -_Returns_ - -- `Object`: Action object. - ### setIsWidgetAreaOpen Sets the open state of the widget area. diff --git a/package-lock.json b/package-lock.json index 326c7ac7bf80c..17848cfac1351 100644 --- a/package-lock.json +++ b/package-lock.json @@ -54822,6 +54822,7 @@ "@wordpress/data": "file:../data", "@wordpress/deprecated": "file:../deprecated", "@wordpress/dom": "file:../dom", + "@wordpress/editor": "file:../editor", "@wordpress/element": "file:../element", "@wordpress/hooks": "file:../hooks", "@wordpress/i18n": "file:../i18n", @@ -69751,6 +69752,7 @@ "@wordpress/data": "file:../data", "@wordpress/deprecated": "file:../deprecated", "@wordpress/dom": "file:../dom", + "@wordpress/editor": "file:../editor", "@wordpress/element": "file:../element", "@wordpress/hooks": "file:../hooks", "@wordpress/i18n": "file:../i18n", diff --git a/packages/edit-widgets/package.json b/packages/edit-widgets/package.json index 974a0ba02905f..40e980fd862b0 100644 --- a/packages/edit-widgets/package.json +++ b/packages/edit-widgets/package.json @@ -37,6 +37,7 @@ "@wordpress/data": "file:../data", "@wordpress/deprecated": "file:../deprecated", "@wordpress/dom": "file:../dom", + "@wordpress/editor": "file:../editor", "@wordpress/element": "file:../element", "@wordpress/hooks": "file:../hooks", "@wordpress/i18n": "file:../i18n", diff --git a/packages/edit-widgets/src/components/header/document-tools/index.js b/packages/edit-widgets/src/components/header/document-tools/index.js deleted file mode 100644 index a9799ac993f9a..0000000000000 --- a/packages/edit-widgets/src/components/header/document-tools/index.js +++ /dev/null @@ -1,125 +0,0 @@ -/** - * WordPress dependencies - */ -import { useSelect, useDispatch } from '@wordpress/data'; -import { __, _x } from '@wordpress/i18n'; -import { Button, ToolbarItem } from '@wordpress/components'; -import { - NavigableToolbar, - store as blockEditorStore, - privateApis as blockEditorPrivateApis, -} from '@wordpress/block-editor'; -import { listView, plus } from '@wordpress/icons'; -import { useCallback, useRef } from '@wordpress/element'; -import { useViewportMatch } from '@wordpress/compose'; - -/** - * Internal dependencies - */ -import UndoButton from '../undo-redo/undo'; -import RedoButton from '../undo-redo/redo'; -import useLastSelectedWidgetArea from '../../../hooks/use-last-selected-widget-area'; -import { store as editWidgetsStore } from '../../../store'; -import { unlock } from '../../../lock-unlock'; - -const { useCanBlockToolbarBeFocused } = unlock( blockEditorPrivateApis ); - -function DocumentTools() { - const isMediumViewport = useViewportMatch( 'medium' ); - const inserterButton = useRef(); - const widgetAreaClientId = useLastSelectedWidgetArea(); - const isLastSelectedWidgetAreaOpen = useSelect( - ( select ) => - select( editWidgetsStore ).getIsWidgetAreaOpen( - widgetAreaClientId - ), - [ widgetAreaClientId ] - ); - const { isInserterOpen, isListViewOpen, listViewToggleRef } = useSelect( - ( select ) => { - const { isInserterOpened, isListViewOpened, getListViewToggleRef } = - unlock( select( editWidgetsStore ) ); - return { - isInserterOpen: isInserterOpened(), - isListViewOpen: isListViewOpened(), - listViewToggleRef: getListViewToggleRef(), - }; - }, - [] - ); - const { setIsWidgetAreaOpen, setIsInserterOpened, setIsListViewOpened } = - useDispatch( editWidgetsStore ); - const { selectBlock } = useDispatch( blockEditorStore ); - const handleClick = () => { - if ( isInserterOpen ) { - // Focusing the inserter button closes the inserter popover. - setIsInserterOpened( false ); - } else { - if ( ! isLastSelectedWidgetAreaOpen ) { - // Select the last selected block if hasn't already. - selectBlock( widgetAreaClientId ); - // Open the last selected widget area when opening the inserter. - setIsWidgetAreaOpen( widgetAreaClientId, true ); - } - // The DOM updates resulting from selectBlock() and setIsInserterOpened() calls are applied the - // same tick and pretty much in a random order. The inserter is closed if any other part of the - // app receives focus. If selectBlock() happens to take effect after setIsInserterOpened() then - // the inserter is visible for a brief moment and then gets auto-closed due to focus moving to - // the selected block. - window.requestAnimationFrame( () => setIsInserterOpened( true ) ); - } - }; - - const toggleListView = useCallback( - () => setIsListViewOpened( ! isListViewOpen ), - [ setIsListViewOpened, isListViewOpen ] - ); - - // If there's a block toolbar to be focused, disable the focus shortcut for the document toolbar. - const blockToolbarCanBeFocused = useCanBlockToolbarBeFocused(); - - return ( - - { - event.preventDefault(); - } } - onClick={ handleClick } - icon={ plus } - /* translators: button label text should, if possible, be under 16 - characters. */ - label={ _x( - 'Toggle block inserter', - 'Generic label for block inserter button' - ) } - /> - { isMediumViewport && ( - <> - - - - - ) } - - ); -} - -export default DocumentTools; diff --git a/packages/edit-widgets/src/components/header/index.js b/packages/edit-widgets/src/components/header/index.js index 0aadec83d5d2f..0c0e429c0e339 100644 --- a/packages/edit-widgets/src/components/header/index.js +++ b/packages/edit-widgets/src/components/header/index.js @@ -1,7 +1,13 @@ +/** + * External dependencies + */ +import classnames from 'classnames'; + /** * WordPress dependencies */ import { BlockToolbar } from '@wordpress/block-editor'; +import { privateApis as editorPrivateApis } from '@wordpress/editor'; import { useSelect } from '@wordpress/data'; import { useRef } from '@wordpress/element'; import { __ } from '@wordpress/i18n'; @@ -13,27 +19,35 @@ import { store as preferencesStore } from '@wordpress/preferences'; /** * Internal dependencies */ -import DocumentTools from './document-tools'; import SaveButton from '../save-button'; import MoreMenu from '../more-menu'; +import { unlock } from '../../lock-unlock'; + +const { DocumentTools } = unlock( editorPrivateApis ); function Header() { const isLargeViewport = useViewportMatch( 'medium' ); const blockToolbarRef = useRef(); - const { hasFixedToolbar } = useSelect( - ( select ) => ( { - hasFixedToolbar: !! select( preferencesStore ).get( + const { hasFixedToolbar, showIconLabels } = useSelect( ( select ) => { + const { get: getPreference } = select( preferencesStore ); + + return { + hasFixedToolbar: !! getPreference( 'core/edit-widgets', 'fixedToolbar' ), - } ), - [] - ); + showIconLabels: getPreference( 'core', 'showIconLabels' ), + }; + }, [] ); return ( <> -
-
+
+
{ isLargeViewport && (

{ __( 'Widgets' ) } @@ -63,7 +77,7 @@ function Header() {
- +

diff --git a/packages/edit-widgets/src/components/header/style.scss b/packages/edit-widgets/src/components/header/style.scss index 2dd4b88eebddf..ff307b498a88b 100644 --- a/packages/edit-widgets/src/components/header/style.scss +++ b/packages/edit-widgets/src/components/header/style.scss @@ -40,80 +40,73 @@ } } -.edit-widgets-header__navigable-toolbar-wrapper { +.edit-widgets-header__toolbar { display: flex; align-items: center; justify-content: center; flex-shrink: 2; overflow-x: hidden; - padding-left: $grid-unit-20; + // Leave enough room for the focus ring to show. + padding: 2px 0; + + @include break-small () { + padding-left: $grid-unit-20; + } } .edit-widgets-header__title { font-size: 20px; padding: 0; - margin: 0 20px 0 0; + margin: 0; } .edit-widgets-header__actions { display: flex; align-items: center; - padding-right: $grid-unit-20; - gap: $grid-unit-05; + padding-right: $grid-unit-05; - @include break-small() { - gap: $grid-unit-10; + @include break-small () { + padding-right: $grid-unit-20 - ($grid-unit-15 * 0.5); } + + gap: $grid-unit-10; } -.edit-widgets-header-toolbar { - border: none; +/** + * Show icon labels. + */ - // The Toolbar component adds different styles to buttons, so we reset them - // here to the original button styles - // Specificity bump needed to offset https://github.com/WordPress/gutenberg/blob/8ea29cb04412c80c9adf7c1db0e816d6a0ac1232/packages/components/src/toolbar/style.scss#L76 - > .components-button.has-icon.has-icon.has-icon, - > .components-dropdown > .components-button.has-icon.has-icon { - height: $button-size; - min-width: $button-size; - padding: 6px; +.show-icon-labels.interface-pinned-items, +.show-icon-labels.edit-widgets-header { + .components-button.has-icon { + width: auto; - &.is-pressed { - background: $gray-900; + // Hide the button icons when labels are set to display... + svg { + display: none; } - - &:focus:not(:disabled) { - box-shadow: 0 0 0 var(--wp-admin-border-width-focus) var(--wp-admin-theme-color), inset 0 0 0 $border-width $white; - outline: 1px solid transparent; + // ... and display labels. + &::after { + content: attr(aria-label); } - - &::before { - display: none; + &[aria-disabled="true"] { + background-color: transparent; } } -} - -.edit-widgets-header-toolbar__inserter-toggle.edit-widgets-header-toolbar__inserter-toggle { - padding-left: $grid-unit; - padding-right: $grid-unit; - - @include break-small { - padding-left: $grid-unit-15; - padding-right: $grid-unit-15; - } - - &::after { - content: none; + .is-tertiary { + &:active { + box-shadow: 0 0 0 1.5px var(--wp-admin-theme-color); + background-color: transparent; + } } - svg { - transition: transform cubic-bezier(0.165, 0.84, 0.44, 1) 0.2s; - @include reduce-motion("transition"); - } + .interface-pinned-items .components-button { + padding-left: $grid-unit; + padding-right: $grid-unit; - &.is-pressed { - svg { - transform: rotate(45deg); + @include break-small { + padding-left: $grid-unit-15; + padding-right: $grid-unit-15; } } } diff --git a/packages/edit-widgets/src/components/header/undo-redo/redo.js b/packages/edit-widgets/src/components/header/undo-redo/redo.js deleted file mode 100644 index c4f4e6df37b91..0000000000000 --- a/packages/edit-widgets/src/components/header/undo-redo/redo.js +++ /dev/null @@ -1,33 +0,0 @@ -/** - * WordPress dependencies - */ -import { __, isRTL } from '@wordpress/i18n'; -import { ToolbarButton } from '@wordpress/components'; -import { useSelect, useDispatch } from '@wordpress/data'; -import { redo as redoIcon, undo as undoIcon } from '@wordpress/icons'; -import { displayShortcut, isAppleOS } from '@wordpress/keycodes'; -import { store as coreStore } from '@wordpress/core-data'; - -export default function RedoButton() { - const shortcut = isAppleOS() - ? displayShortcut.primaryShift( 'z' ) - : displayShortcut.primary( 'y' ); - - const hasRedo = useSelect( - ( select ) => select( coreStore ).hasRedo(), - [] - ); - const { redo } = useDispatch( coreStore ); - return ( - - ); -} diff --git a/packages/edit-widgets/src/components/header/undo-redo/undo.js b/packages/edit-widgets/src/components/header/undo-redo/undo.js deleted file mode 100644 index 827ed1a415d74..0000000000000 --- a/packages/edit-widgets/src/components/header/undo-redo/undo.js +++ /dev/null @@ -1,29 +0,0 @@ -/** - * WordPress dependencies - */ -import { __, isRTL } from '@wordpress/i18n'; -import { ToolbarButton } from '@wordpress/components'; -import { useSelect, useDispatch } from '@wordpress/data'; -import { undo as undoIcon, redo as redoIcon } from '@wordpress/icons'; -import { displayShortcut } from '@wordpress/keycodes'; -import { store as coreStore } from '@wordpress/core-data'; - -export default function UndoButton() { - const hasUndo = useSelect( - ( select ) => select( coreStore ).hasUndo(), - [] - ); - const { undo } = useDispatch( coreStore ); - return ( - - ); -} diff --git a/packages/edit-widgets/src/components/layout/interface.js b/packages/edit-widgets/src/components/layout/interface.js index 987e3868de133..9f022d94f8aa8 100644 --- a/packages/edit-widgets/src/components/layout/interface.js +++ b/packages/edit-widgets/src/components/layout/interface.js @@ -2,7 +2,10 @@ * WordPress dependencies */ import { useViewportMatch } from '@wordpress/compose'; -import { BlockBreadcrumb } from '@wordpress/block-editor'; +import { + BlockBreadcrumb, + store as blockEditorStore, +} from '@wordpress/block-editor'; import { useEffect } from '@wordpress/element'; import { useDispatch, useSelect } from '@wordpress/data'; import { @@ -13,6 +16,7 @@ import { import { __ } from '@wordpress/i18n'; import { store as keyboardShortcutsStore } from '@wordpress/keyboard-shortcuts'; import { store as preferencesStore } from '@wordpress/preferences'; +import { store as editorStore } from '@wordpress/editor'; /** * Internal dependencies @@ -21,6 +25,7 @@ import Header from '../header'; import WidgetAreasBlockEditorContent from '../widget-areas-block-editor-content'; import { store as editWidgetsStore } from '../../store'; import SecondarySidebar from '../secondary-sidebar'; +import useLastSelectedWidgetArea from '../../hooks/use-last-selected-widget-area'; const interfaceLabels = { /* translators: accessibility text for the widgets screen top bar landmark region. */ @@ -36,8 +41,12 @@ const interfaceLabels = { function Interface( { blockEditorSettings } ) { const isMobileViewport = useViewportMatch( 'medium', '<' ); const isHugeViewport = useViewportMatch( 'huge', '>=' ); - const { setIsInserterOpened, setIsListViewOpened, closeGeneralSidebar } = + const widgetAreaClientId = useLastSelectedWidgetArea(); + const { setIsInserterOpened, setIsListViewOpened } = + useDispatch( editorStore ); + const { setIsWidgetAreaOpen, closeGeneralSidebar } = useDispatch( editWidgetsStore ); + const { selectBlock } = useDispatch( blockEditorStore ); const { hasBlockBreadCrumbsEnabled, hasSidebarEnabled, @@ -50,8 +59,8 @@ function Interface( { blockEditorSettings } ) { hasSidebarEnabled: !! select( interfaceStore ).getActiveComplementaryArea( editWidgetsStore.name ), - isInserterOpened: !! select( editWidgetsStore ).isInserterOpened(), - isListViewOpened: !! select( editWidgetsStore ).isListViewOpened(), + isInserterOpened: !! select( editorStore ).isInserterOpened(), + isListViewOpened: !! select( editorStore ).isListViewOpened(), hasBlockBreadCrumbsEnabled: !! select( preferencesStore ).get( 'core/edit-widgets', 'showBlockBreadcrumbs' @@ -68,6 +77,14 @@ function Interface( { blockEditorSettings } ) { [] ); + const isLastSelectedWidgetAreaOpen = useSelect( + ( select ) => + select( editWidgetsStore ).getIsWidgetAreaOpen( + widgetAreaClientId + ), + [ widgetAreaClientId ] + ); + // Inserter and Sidebars are mutually exclusive useEffect( () => { if ( hasSidebarEnabled && ! isHugeViewport ) { @@ -82,6 +99,21 @@ function Interface( { blockEditorSettings } ) { } }, [ isInserterOpened, isListViewOpened, isHugeViewport ] ); + useEffect( () => { + if ( isInserterOpened && ! isLastSelectedWidgetAreaOpen ) { + // Select the last selected block if hasn't already. + selectBlock( widgetAreaClientId ); + // Open the last selected widget area when opening the inserter. + setIsWidgetAreaOpen( widgetAreaClientId, true ); + } + }, [ + widgetAreaClientId, + isInserterOpened, + isLastSelectedWidgetAreaOpen, + selectBlock, + setIsWidgetAreaOpen, + ] ); + const secondarySidebarLabel = isListViewOpened ? __( 'List View' ) : __( 'Block Library' ); diff --git a/packages/edit-widgets/src/components/more-menu/index.js b/packages/edit-widgets/src/components/more-menu/index.js index bb3e01bd19e26..a954cbb9aed9e 100644 --- a/packages/edit-widgets/src/components/more-menu/index.js +++ b/packages/edit-widgets/src/components/more-menu/index.js @@ -17,7 +17,7 @@ import { useViewportMatch } from '@wordpress/compose'; import KeyboardShortcutHelpModal from '../keyboard-shortcut-help-modal'; import ToolsMoreMenuGroup from './tools-more-menu-group'; -export default function MoreMenu() { +export default function MoreMenu( { showIconLabels } ) { const [ isKeyboardShortcutsModalActive, setIsKeyboardShortcutsModalVisible, @@ -34,7 +34,12 @@ export default function MoreMenu() { return ( <> - + { ( onClose ) => ( <> { isLargeViewport && ( diff --git a/packages/edit-widgets/src/components/secondary-sidebar/index.js b/packages/edit-widgets/src/components/secondary-sidebar/index.js index 49e240bd147cb..e1dcb7677d7ae 100644 --- a/packages/edit-widgets/src/components/secondary-sidebar/index.js +++ b/packages/edit-widgets/src/components/secondary-sidebar/index.js @@ -2,10 +2,7 @@ * WordPress dependencies */ import { useSelect } from '@wordpress/data'; -/** - * Internal dependencies - */ -import { store as editWidgetsStore } from '../../store'; +import { store as editorStore } from '@wordpress/editor'; /** * Internal dependencies @@ -15,8 +12,7 @@ import ListViewSidebar from './list-view-sidebar'; export default function SecondarySidebar() { const { isInserterOpen, isListViewOpen } = useSelect( ( select ) => { - const { isInserterOpened, isListViewOpened } = - select( editWidgetsStore ); + const { isInserterOpened, isListViewOpened } = select( editorStore ); return { isInserterOpen: isInserterOpened(), isListViewOpen: isListViewOpened(), diff --git a/packages/edit-widgets/src/components/secondary-sidebar/inserter-sidebar.js b/packages/edit-widgets/src/components/secondary-sidebar/inserter-sidebar.js index b01481748ee88..2b4b16cc4d093 100644 --- a/packages/edit-widgets/src/components/secondary-sidebar/inserter-sidebar.js +++ b/packages/edit-widgets/src/components/secondary-sidebar/inserter-sidebar.js @@ -11,18 +11,18 @@ import { import { useCallback, useEffect, useRef } from '@wordpress/element'; import { useDispatch } from '@wordpress/data'; import { __ } from '@wordpress/i18n'; +import { store as editorStore } from '@wordpress/editor'; /** * Internal dependencies */ import useWidgetLibraryInsertionPoint from '../../hooks/use-widget-library-insertion-point'; -import { store as editWidgetsStore } from '../../store'; export default function InserterSidebar() { const isMobileViewport = useViewportMatch( 'medium', '<' ); const { rootClientId, insertionIndex } = useWidgetLibraryInsertionPoint(); - const { setIsInserterOpened } = useDispatch( editWidgetsStore ); + const { setIsInserterOpened } = useDispatch( editorStore ); const closeInserter = useCallback( () => { return setIsInserterOpened( false ); diff --git a/packages/edit-widgets/src/components/secondary-sidebar/list-view-sidebar.js b/packages/edit-widgets/src/components/secondary-sidebar/list-view-sidebar.js index 6aa2123a6774a..252020c2db3a6 100644 --- a/packages/edit-widgets/src/components/secondary-sidebar/list-view-sidebar.js +++ b/packages/edit-widgets/src/components/secondary-sidebar/list-view-sidebar.js @@ -9,16 +9,16 @@ import { useCallback, useState } from '@wordpress/element'; import { __ } from '@wordpress/i18n'; import { closeSmall } from '@wordpress/icons'; import { ESCAPE } from '@wordpress/keycodes'; +import { store as editorStore } from '@wordpress/editor'; /** * Internal dependencies */ -import { store as editWidgetsStore } from '../../store'; import { unlock } from '../../lock-unlock'; export default function ListViewSidebar() { - const { setIsListViewOpened } = useDispatch( editWidgetsStore ); - const { getListViewToggleRef } = unlock( useSelect( editWidgetsStore ) ); + const { setIsListViewOpened } = useDispatch( editorStore ); + const { getListViewToggleRef } = unlock( useSelect( editorStore ) ); // Use internal state instead of a ref to make sure that the component // re-renders when the dropZoneElement updates. diff --git a/packages/edit-widgets/src/components/widget-areas-block-editor-provider/index.js b/packages/edit-widgets/src/components/widget-areas-block-editor-provider/index.js index 4abc420434cc4..4e19e09593e91 100644 --- a/packages/edit-widgets/src/components/widget-areas-block-editor-provider/index.js +++ b/packages/edit-widgets/src/components/widget-areas-block-editor-provider/index.js @@ -14,6 +14,7 @@ import { useMemo } from '@wordpress/element'; import { privateApis as blockEditorPrivateApis } from '@wordpress/block-editor'; import { privateApis as editPatternsPrivateApis } from '@wordpress/patterns'; import { store as preferencesStore } from '@wordpress/preferences'; +import { store as editorStore } from '@wordpress/editor'; /** * Internal dependencies @@ -64,7 +65,7 @@ export default function WidgetAreasBlockEditorProvider( { pageForPosts: siteSettings?.page_for_posts, }; }, [] ); - const { setIsInserterOpened } = useDispatch( editWidgetsStore ); + const { setIsInserterOpened } = useDispatch( editorStore ); const settings = useMemo( () => { let mediaUploadBlockEditor; diff --git a/packages/edit-widgets/src/store/actions.js b/packages/edit-widgets/src/store/actions.js index 8124ace66bdb3..6fb9e5ac88807 100644 --- a/packages/edit-widgets/src/store/actions.js +++ b/packages/edit-widgets/src/store/actions.js @@ -2,11 +2,13 @@ * WordPress dependencies */ import { __, sprintf } from '@wordpress/i18n'; +import deprecated from '@wordpress/deprecated'; import { store as noticesStore } from '@wordpress/notices'; import { store as interfaceStore } from '@wordpress/interface'; import { getWidgetIdFromBlock } from '@wordpress/widgets'; import { store as coreStore } from '@wordpress/core-data'; import { store as blockEditorStore } from '@wordpress/block-editor'; +import { store as editorStore } from '@wordpress/editor'; /** * Internal dependencies @@ -342,34 +344,36 @@ export function setIsWidgetAreaOpen( clientId, isOpen ) { /** * Returns an action object used to open/close the inserter. * - * @param {boolean|Object} value Whether the inserter should be - * opened (true) or closed (false). - * To specify an insertion point, - * use an object. - * @param {string} value.rootClientId The root client ID to insert at. - * @param {number} value.insertionIndex The index to insert at. + * @deprecated * - * @return {Object} Action object. + * @param {boolean|Object} value Whether the inserter should be opened (true) or closed (false). */ -export function setIsInserterOpened( value ) { - return { - type: 'SET_IS_INSERTER_OPENED', - value, +export const setIsInserterOpened = + ( value ) => + ( { registry } ) => { + deprecated( "dispatch( 'core/edit-widgets' ).setIsInserterOpened", { + since: '6.5', + alternative: "dispatch( 'core/editor').setIsInserterOpened", + } ); + registry.dispatch( editorStore ).setIsInserterOpened( value ); }; -} /** * Returns an action object used to open/close the list view. * + * @deprecated + * * @param {boolean} isOpen A boolean representing whether the list view should be opened or closed. - * @return {Object} Action object. */ -export function setIsListViewOpened( isOpen ) { - return { - type: 'SET_IS_LIST_VIEW_OPENED', - isOpen, +export const setIsListViewOpened = + ( isOpen ) => + ( { registry } ) => { + deprecated( "dispatch( 'core/edit-widgets' ).setIsListViewOpened", { + since: '6.5', + alternative: "dispatch( 'core/editor').setIsListViewOpened", + } ); + registry.dispatch( editorStore ).setIsListViewOpened( isOpen ); }; -} /** * Returns an action object signalling that the user closed the sidebar. diff --git a/test/e2e/specs/widgets/editing-widgets.spec.js b/test/e2e/specs/widgets/editing-widgets.spec.js index 28e9aac437572..1f256ca8eec58 100644 --- a/test/e2e/specs/widgets/editing-widgets.spec.js +++ b/test/e2e/specs/widgets/editing-widgets.spec.js @@ -609,7 +609,7 @@ test.describe( 'Widgets screen', () => { test( 'can toggle sidebar list view', async ( { page } ) => { const toggleListViewButton = page .getByRole( 'toolbar', { name: 'Document tools' } ) - .getByRole( 'button', { name: 'List View' } ); + .getByRole( 'button', { name: 'Document Overview' } ); await toggleListViewButton.click(); const listView = page.getByRole( 'treegrid', {