@wordpress/edit-widgets 5.25.0 → 5.25.1-next.79a6196f.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.md +1 -1
- package/build/blocks/widget-area/index.js +1 -0
- package/build/blocks/widget-area/index.js.map +1 -1
- package/build/components/header/document-tools/index.js +19 -18
- package/build/components/header/document-tools/index.js.map +1 -1
- package/build/components/header/index.js +2 -6
- package/build/components/header/index.js.map +1 -1
- package/build/components/header/undo-redo/redo.js +8 -3
- package/build/components/header/undo-redo/redo.js.map +1 -1
- package/build/components/header/undo-redo/undo.js +8 -3
- package/build/components/header/undo-redo/undo.js.map +1 -1
- package/build/components/layout/interface.js +2 -7
- package/build/components/layout/interface.js.map +1 -1
- package/build/components/secondary-sidebar/index.js +2 -6
- package/build/components/secondary-sidebar/index.js.map +1 -1
- package/build/components/secondary-sidebar/list-view-sidebar.js +7 -5
- package/build/components/secondary-sidebar/list-view-sidebar.js.map +1 -1
- package/build/store/index.js +3 -0
- package/build/store/index.js.map +1 -1
- package/build/store/private-selectors.js +10 -0
- package/build/store/private-selectors.js.map +1 -0
- package/build/store/reducer.js +14 -0
- package/build/store/reducer.js.map +1 -1
- package/build-module/blocks/widget-area/index.js +1 -0
- package/build-module/blocks/widget-area/index.js.map +1 -1
- package/build-module/components/header/document-tools/index.js +19 -18
- package/build-module/components/header/document-tools/index.js.map +1 -1
- package/build-module/components/header/index.js +2 -6
- package/build-module/components/header/index.js.map +1 -1
- package/build-module/components/header/undo-redo/redo.js +7 -3
- package/build-module/components/header/undo-redo/redo.js.map +1 -1
- package/build-module/components/header/undo-redo/undo.js +7 -3
- package/build-module/components/header/undo-redo/undo.js.map +1 -1
- package/build-module/components/layout/interface.js +3 -8
- package/build-module/components/layout/interface.js.map +1 -1
- package/build-module/components/secondary-sidebar/index.js +2 -6
- package/build-module/components/secondary-sidebar/index.js.map +1 -1
- package/build-module/components/secondary-sidebar/list-view-sidebar.js +8 -6
- package/build-module/components/secondary-sidebar/list-view-sidebar.js.map +1 -1
- package/build-module/store/index.js +3 -0
- package/build-module/store/index.js.map +1 -1
- package/build-module/store/private-selectors.js +4 -0
- package/build-module/store/private-selectors.js.map +1 -0
- package/build-module/store/reducer.js +13 -0
- package/build-module/store/reducer.js.map +1 -1
- package/build-style/style-rtl.css +5 -2
- package/build-style/style.css +5 -2
- package/package.json +30 -29
- package/src/blocks/widget-area/block.json +1 -0
- package/src/components/header/document-tools/index.js +19 -23
- package/src/components/header/index.js +2 -4
- package/src/components/header/style.scss +1 -2
- package/src/components/header/undo-redo/redo.js +8 -3
- package/src/components/header/undo-redo/undo.js +8 -3
- package/src/components/layout/interface.js +3 -14
- package/src/components/secondary-sidebar/index.js +2 -4
- package/src/components/secondary-sidebar/list-view-sidebar.js +6 -4
- package/src/store/index.js +4 -0
- package/src/store/private-selectors.js +3 -0
- package/src/store/reducer.js +11 -0
|
@@ -569,6 +569,10 @@ body.is-fullscreen-mode .interface-interface-skeleton {
|
|
|
569
569
|
color: #757575;
|
|
570
570
|
}
|
|
571
571
|
|
|
572
|
+
.interface-preferences-modal__section:has(.interface-preferences-modal__section-content:empty) {
|
|
573
|
+
display: none;
|
|
574
|
+
}
|
|
575
|
+
|
|
572
576
|
.interface-preferences-modal__option + .interface-preferences-modal__option {
|
|
573
577
|
margin-top: 16px;
|
|
574
578
|
}
|
|
@@ -674,7 +678,6 @@ body.is-dragging-components-draggable .wp-block[data-type="core/widget-area"] .c
|
|
|
674
678
|
align-items: center;
|
|
675
679
|
justify-content: center;
|
|
676
680
|
flex-shrink: 2;
|
|
677
|
-
overflow-x: hidden;
|
|
678
681
|
padding-right: 16px;
|
|
679
682
|
}
|
|
680
683
|
|
|
@@ -697,7 +700,7 @@ body.is-dragging-components-draggable .wp-block[data-type="core/widget-area"] .c
|
|
|
697
700
|
}
|
|
698
701
|
|
|
699
702
|
.edit-widgets-header-toolbar {
|
|
700
|
-
|
|
703
|
+
gap: 8px;
|
|
701
704
|
}
|
|
702
705
|
.edit-widgets-header-toolbar > .components-button.has-icon.has-icon.has-icon,
|
|
703
706
|
.edit-widgets-header-toolbar > .components-dropdown > .components-button.has-icon.has-icon {
|
package/build-style/style.css
CHANGED
|
@@ -569,6 +569,10 @@ body.is-fullscreen-mode .interface-interface-skeleton {
|
|
|
569
569
|
color: #757575;
|
|
570
570
|
}
|
|
571
571
|
|
|
572
|
+
.interface-preferences-modal__section:has(.interface-preferences-modal__section-content:empty) {
|
|
573
|
+
display: none;
|
|
574
|
+
}
|
|
575
|
+
|
|
572
576
|
.interface-preferences-modal__option + .interface-preferences-modal__option {
|
|
573
577
|
margin-top: 16px;
|
|
574
578
|
}
|
|
@@ -674,7 +678,6 @@ body.is-dragging-components-draggable .wp-block[data-type="core/widget-area"] .c
|
|
|
674
678
|
align-items: center;
|
|
675
679
|
justify-content: center;
|
|
676
680
|
flex-shrink: 2;
|
|
677
|
-
overflow-x: hidden;
|
|
678
681
|
padding-left: 16px;
|
|
679
682
|
}
|
|
680
683
|
|
|
@@ -697,7 +700,7 @@ body.is-dragging-components-draggable .wp-block[data-type="core/widget-area"] .c
|
|
|
697
700
|
}
|
|
698
701
|
|
|
699
702
|
.edit-widgets-header-toolbar {
|
|
700
|
-
|
|
703
|
+
gap: 8px;
|
|
701
704
|
}
|
|
702
705
|
.edit-widgets-header-toolbar > .components-button.has-icon.has-icon.has-icon,
|
|
703
706
|
.edit-widgets-header-toolbar > .components-dropdown > .components-button.has-icon.has-icon {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wordpress/edit-widgets",
|
|
3
|
-
"version": "5.25.0",
|
|
3
|
+
"version": "5.25.1-next.79a6196f.0",
|
|
4
4
|
"description": "Widgets Page module for WordPress..",
|
|
5
5
|
"author": "The WordPress Contributors",
|
|
6
6
|
"license": "GPL-2.0-or-later",
|
|
@@ -27,33 +27,34 @@
|
|
|
27
27
|
"react-native": "src/index",
|
|
28
28
|
"dependencies": {
|
|
29
29
|
"@babel/runtime": "^7.16.0",
|
|
30
|
-
"@wordpress/api-fetch": "^6.45.0",
|
|
31
|
-
"@wordpress/block-editor": "^12.16.0",
|
|
32
|
-
"@wordpress/block-library": "^8.25.0",
|
|
33
|
-
"@wordpress/blocks": "^12.25.0",
|
|
34
|
-
"@wordpress/components": "^25.
|
|
35
|
-
"@wordpress/compose": "^6.25.0",
|
|
36
|
-
"@wordpress/core-data": "^6.25.0",
|
|
37
|
-
"@wordpress/data": "^9.18.0",
|
|
38
|
-
"@wordpress/deprecated": "^3.48.0",
|
|
39
|
-
"@wordpress/dom": "^3.48.0",
|
|
40
|
-
"@wordpress/element": "^5.25.0",
|
|
41
|
-
"@wordpress/hooks": "^3.48.0",
|
|
42
|
-
"@wordpress/i18n": "^4.48.0",
|
|
43
|
-
"@wordpress/icons": "^9.39.0",
|
|
44
|
-
"@wordpress/interface": "^5.25.0",
|
|
45
|
-
"@wordpress/keyboard-shortcuts": "^4.25.0",
|
|
46
|
-
"@wordpress/keycodes": "^3.48.0",
|
|
47
|
-
"@wordpress/media-utils": "^4.39.0",
|
|
48
|
-
"@wordpress/notices": "^4.16.0",
|
|
49
|
-
"@wordpress/patterns": "^1.9.0",
|
|
50
|
-
"@wordpress/plugins": "^6.16.0",
|
|
51
|
-
"@wordpress/preferences": "^3.25.0",
|
|
52
|
-
"@wordpress/private-apis": "^0.30.0",
|
|
53
|
-
"@wordpress/reusable-blocks": "^4.25.0",
|
|
54
|
-
"@wordpress/url": "^3.49.0",
|
|
55
|
-
"@wordpress/widgets": "^3.25.0",
|
|
56
|
-
"classnames": "^2.3.1"
|
|
30
|
+
"@wordpress/api-fetch": "^6.45.1-next.79a6196f.0",
|
|
31
|
+
"@wordpress/block-editor": "^12.16.1-next.79a6196f.0",
|
|
32
|
+
"@wordpress/block-library": "^8.25.1-next.79a6196f.0",
|
|
33
|
+
"@wordpress/blocks": "^12.25.1-next.79a6196f.0",
|
|
34
|
+
"@wordpress/components": "^25.15.1-next.79a6196f.0",
|
|
35
|
+
"@wordpress/compose": "^6.25.1-next.79a6196f.0",
|
|
36
|
+
"@wordpress/core-data": "^6.25.1-next.79a6196f.0",
|
|
37
|
+
"@wordpress/data": "^9.18.1-next.79a6196f.0",
|
|
38
|
+
"@wordpress/deprecated": "^3.48.1-next.79a6196f.0",
|
|
39
|
+
"@wordpress/dom": "^3.48.1-next.79a6196f.0",
|
|
40
|
+
"@wordpress/element": "^5.25.1-next.79a6196f.0",
|
|
41
|
+
"@wordpress/hooks": "^3.48.1-next.79a6196f.0",
|
|
42
|
+
"@wordpress/i18n": "^4.48.1-next.79a6196f.0",
|
|
43
|
+
"@wordpress/icons": "^9.39.1-next.79a6196f.0",
|
|
44
|
+
"@wordpress/interface": "^5.25.1-next.79a6196f.0",
|
|
45
|
+
"@wordpress/keyboard-shortcuts": "^4.25.1-next.79a6196f.0",
|
|
46
|
+
"@wordpress/keycodes": "^3.48.1-next.79a6196f.0",
|
|
47
|
+
"@wordpress/media-utils": "^4.39.1-next.79a6196f.0",
|
|
48
|
+
"@wordpress/notices": "^4.16.1-next.79a6196f.0",
|
|
49
|
+
"@wordpress/patterns": "^1.9.1-next.79a6196f.0",
|
|
50
|
+
"@wordpress/plugins": "^6.16.1-next.79a6196f.0",
|
|
51
|
+
"@wordpress/preferences": "^3.25.1-next.79a6196f.0",
|
|
52
|
+
"@wordpress/private-apis": "^0.30.1-next.79a6196f.0",
|
|
53
|
+
"@wordpress/reusable-blocks": "^4.25.1-next.79a6196f.0",
|
|
54
|
+
"@wordpress/url": "^3.49.1-next.79a6196f.0",
|
|
55
|
+
"@wordpress/widgets": "^3.25.1-next.79a6196f.0",
|
|
56
|
+
"classnames": "^2.3.1",
|
|
57
|
+
"rememo": "^4.0.2"
|
|
57
58
|
},
|
|
58
59
|
"peerDependencies": {
|
|
59
60
|
"react": "^18.0.0",
|
|
@@ -62,5 +63,5 @@
|
|
|
62
63
|
"publishConfig": {
|
|
63
64
|
"access": "public"
|
|
64
65
|
},
|
|
65
|
-
"gitHead": "
|
|
66
|
+
"gitHead": "1e74b942ac0119a22ceaaf5c9594263f3ec516ab"
|
|
66
67
|
}
|
|
@@ -22,9 +22,9 @@ import useLastSelectedWidgetArea from '../../../hooks/use-last-selected-widget-a
|
|
|
22
22
|
import { store as editWidgetsStore } from '../../../store';
|
|
23
23
|
import { unlock } from '../../../lock-unlock';
|
|
24
24
|
|
|
25
|
-
const {
|
|
25
|
+
const { useCanBlockToolbarBeFocused } = unlock( blockEditorPrivateApis );
|
|
26
26
|
|
|
27
|
-
function DocumentTools(
|
|
27
|
+
function DocumentTools() {
|
|
28
28
|
const isMediumViewport = useViewportMatch( 'medium' );
|
|
29
29
|
const inserterButton = useRef();
|
|
30
30
|
const widgetAreaClientId = useLastSelectedWidgetArea();
|
|
@@ -35,14 +35,18 @@ function DocumentTools( { setListViewToggleElement } ) {
|
|
|
35
35
|
),
|
|
36
36
|
[ widgetAreaClientId ]
|
|
37
37
|
);
|
|
38
|
-
const { isInserterOpen, isListViewOpen } = useSelect(
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
38
|
+
const { isInserterOpen, isListViewOpen, listViewToggleRef } = useSelect(
|
|
39
|
+
( select ) => {
|
|
40
|
+
const { isInserterOpened, isListViewOpened, getListViewToggleRef } =
|
|
41
|
+
unlock( select( editWidgetsStore ) );
|
|
42
|
+
return {
|
|
43
|
+
isInserterOpen: isInserterOpened(),
|
|
44
|
+
isListViewOpen: isListViewOpened(),
|
|
45
|
+
listViewToggleRef: getListViewToggleRef(),
|
|
46
|
+
};
|
|
47
|
+
},
|
|
48
|
+
[]
|
|
49
|
+
);
|
|
46
50
|
const { setIsWidgetAreaOpen, setIsInserterOpened, setIsListViewOpened } =
|
|
47
51
|
useDispatch( editWidgetsStore );
|
|
48
52
|
const { selectBlock } = useDispatch( blockEditorStore );
|
|
@@ -71,23 +75,15 @@ function DocumentTools( { setListViewToggleElement } ) {
|
|
|
71
75
|
[ setIsListViewOpened, isListViewOpen ]
|
|
72
76
|
);
|
|
73
77
|
|
|
74
|
-
const {
|
|
75
|
-
shouldShowContextualToolbar,
|
|
76
|
-
canFocusHiddenToolbar,
|
|
77
|
-
fixedToolbarCanBeFocused,
|
|
78
|
-
} = useShouldContextualToolbarShow();
|
|
79
78
|
// If there's a block toolbar to be focused, disable the focus shortcut for the document toolbar.
|
|
80
|
-
|
|
81
|
-
const blockToolbarCanBeFocused =
|
|
82
|
-
shouldShowContextualToolbar ||
|
|
83
|
-
canFocusHiddenToolbar ||
|
|
84
|
-
fixedToolbarCanBeFocused;
|
|
79
|
+
const blockToolbarCanBeFocused = useCanBlockToolbarBeFocused();
|
|
85
80
|
|
|
86
81
|
return (
|
|
87
82
|
<NavigableToolbar
|
|
88
83
|
className="edit-widgets-header-toolbar"
|
|
89
84
|
aria-label={ __( 'Document tools' ) }
|
|
90
85
|
shouldUseKeyboardFocusShortcut={ ! blockToolbarCanBeFocused }
|
|
86
|
+
variant="unstyled"
|
|
91
87
|
>
|
|
92
88
|
<ToolbarItem
|
|
93
89
|
ref={ inserterButton }
|
|
@@ -109,8 +105,8 @@ function DocumentTools( { setListViewToggleElement } ) {
|
|
|
109
105
|
/>
|
|
110
106
|
{ isMediumViewport && (
|
|
111
107
|
<>
|
|
112
|
-
<UndoButton />
|
|
113
|
-
<RedoButton />
|
|
108
|
+
<ToolbarItem as={ UndoButton } />
|
|
109
|
+
<ToolbarItem as={ RedoButton } />
|
|
114
110
|
<ToolbarItem
|
|
115
111
|
as={ Button }
|
|
116
112
|
className="edit-widgets-header-toolbar__list-view-toggle"
|
|
@@ -119,7 +115,7 @@ function DocumentTools( { setListViewToggleElement } ) {
|
|
|
119
115
|
/* translators: button label text should, if possible, be under 16 characters. */
|
|
120
116
|
label={ __( 'List View' ) }
|
|
121
117
|
onClick={ toggleListView }
|
|
122
|
-
ref={
|
|
118
|
+
ref={ listViewToggleRef }
|
|
123
119
|
/>
|
|
124
120
|
</>
|
|
125
121
|
) }
|
|
@@ -17,7 +17,7 @@ import DocumentTools from './document-tools';
|
|
|
17
17
|
import SaveButton from '../save-button';
|
|
18
18
|
import MoreMenu from '../more-menu';
|
|
19
19
|
|
|
20
|
-
function Header(
|
|
20
|
+
function Header() {
|
|
21
21
|
const isLargeViewport = useViewportMatch( 'medium' );
|
|
22
22
|
const blockToolbarRef = useRef();
|
|
23
23
|
const { hasFixedToolbar } = useSelect(
|
|
@@ -47,9 +47,7 @@ function Header( { setListViewToggleElement } ) {
|
|
|
47
47
|
{ __( 'Widgets' ) }
|
|
48
48
|
</VisuallyHidden>
|
|
49
49
|
) }
|
|
50
|
-
<DocumentTools
|
|
51
|
-
setListViewToggleElement={ setListViewToggleElement }
|
|
52
|
-
/>
|
|
50
|
+
<DocumentTools />
|
|
53
51
|
{ hasFixedToolbar && isLargeViewport && (
|
|
54
52
|
<>
|
|
55
53
|
<div className="selected-block-tools-wrapper">
|
|
@@ -45,7 +45,6 @@
|
|
|
45
45
|
align-items: center;
|
|
46
46
|
justify-content: center;
|
|
47
47
|
flex-shrink: 2;
|
|
48
|
-
overflow-x: hidden;
|
|
49
48
|
padding-left: $grid-unit-20;
|
|
50
49
|
}
|
|
51
50
|
|
|
@@ -67,7 +66,7 @@
|
|
|
67
66
|
}
|
|
68
67
|
|
|
69
68
|
.edit-widgets-header-toolbar {
|
|
70
|
-
|
|
69
|
+
gap: $grid-unit-10;
|
|
71
70
|
|
|
72
71
|
// The Toolbar component adds different styles to buttons, so we reset them
|
|
73
72
|
// here to the original button styles
|
|
@@ -2,13 +2,14 @@
|
|
|
2
2
|
* WordPress dependencies
|
|
3
3
|
*/
|
|
4
4
|
import { __, isRTL } from '@wordpress/i18n';
|
|
5
|
-
import {
|
|
5
|
+
import { Button } from '@wordpress/components';
|
|
6
6
|
import { useSelect, useDispatch } from '@wordpress/data';
|
|
7
7
|
import { redo as redoIcon, undo as undoIcon } from '@wordpress/icons';
|
|
8
8
|
import { displayShortcut, isAppleOS } from '@wordpress/keycodes';
|
|
9
9
|
import { store as coreStore } from '@wordpress/core-data';
|
|
10
|
+
import { forwardRef } from '@wordpress/element';
|
|
10
11
|
|
|
11
|
-
|
|
12
|
+
function RedoButton( props, ref ) {
|
|
12
13
|
const shortcut = isAppleOS()
|
|
13
14
|
? displayShortcut.primaryShift( 'z' )
|
|
14
15
|
: displayShortcut.primary( 'y' );
|
|
@@ -19,7 +20,9 @@ export default function RedoButton() {
|
|
|
19
20
|
);
|
|
20
21
|
const { redo } = useDispatch( coreStore );
|
|
21
22
|
return (
|
|
22
|
-
<
|
|
23
|
+
<Button
|
|
24
|
+
{ ...props }
|
|
25
|
+
ref={ ref }
|
|
23
26
|
icon={ ! isRTL() ? redoIcon : undoIcon }
|
|
24
27
|
label={ __( 'Redo' ) }
|
|
25
28
|
shortcut={ shortcut }
|
|
@@ -31,3 +34,5 @@ export default function RedoButton() {
|
|
|
31
34
|
/>
|
|
32
35
|
);
|
|
33
36
|
}
|
|
37
|
+
|
|
38
|
+
export default forwardRef( RedoButton );
|
|
@@ -2,20 +2,23 @@
|
|
|
2
2
|
* WordPress dependencies
|
|
3
3
|
*/
|
|
4
4
|
import { __, isRTL } from '@wordpress/i18n';
|
|
5
|
-
import {
|
|
5
|
+
import { Button } from '@wordpress/components';
|
|
6
6
|
import { useSelect, useDispatch } from '@wordpress/data';
|
|
7
7
|
import { undo as undoIcon, redo as redoIcon } from '@wordpress/icons';
|
|
8
8
|
import { displayShortcut } from '@wordpress/keycodes';
|
|
9
9
|
import { store as coreStore } from '@wordpress/core-data';
|
|
10
|
+
import { forwardRef } from '@wordpress/element';
|
|
10
11
|
|
|
11
|
-
|
|
12
|
+
function UndoButton( props, ref ) {
|
|
12
13
|
const hasUndo = useSelect(
|
|
13
14
|
( select ) => select( coreStore ).hasUndo(),
|
|
14
15
|
[]
|
|
15
16
|
);
|
|
16
17
|
const { undo } = useDispatch( coreStore );
|
|
17
18
|
return (
|
|
18
|
-
<
|
|
19
|
+
<Button
|
|
20
|
+
{ ...props }
|
|
21
|
+
ref={ ref }
|
|
19
22
|
icon={ ! isRTL() ? undoIcon : redoIcon }
|
|
20
23
|
label={ __( 'Undo' ) }
|
|
21
24
|
shortcut={ displayShortcut.primary( 'z' ) }
|
|
@@ -27,3 +30,5 @@ export default function UndoButton() {
|
|
|
27
30
|
/>
|
|
28
31
|
);
|
|
29
32
|
}
|
|
33
|
+
|
|
34
|
+
export default forwardRef( UndoButton );
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import { useViewportMatch } from '@wordpress/compose';
|
|
5
5
|
import { BlockBreadcrumb } from '@wordpress/block-editor';
|
|
6
|
-
import { useEffect
|
|
6
|
+
import { useEffect } from '@wordpress/element';
|
|
7
7
|
import { useDispatch, useSelect } from '@wordpress/data';
|
|
8
8
|
import {
|
|
9
9
|
InterfaceSkeleton,
|
|
@@ -68,9 +68,6 @@ function Interface( { blockEditorSettings } ) {
|
|
|
68
68
|
[]
|
|
69
69
|
);
|
|
70
70
|
|
|
71
|
-
const [ listViewToggleElement, setListViewToggleElement ] =
|
|
72
|
-
useState( null );
|
|
73
|
-
|
|
74
71
|
// Inserter and Sidebars are mutually exclusive
|
|
75
72
|
useEffect( () => {
|
|
76
73
|
if ( hasSidebarEnabled && ! isHugeViewport ) {
|
|
@@ -97,16 +94,8 @@ function Interface( { blockEditorSettings } ) {
|
|
|
97
94
|
...interfaceLabels,
|
|
98
95
|
secondarySidebar: secondarySidebarLabel,
|
|
99
96
|
} }
|
|
100
|
-
header={
|
|
101
|
-
|
|
102
|
-
}
|
|
103
|
-
secondarySidebar={
|
|
104
|
-
hasSecondarySidebar && (
|
|
105
|
-
<SecondarySidebar
|
|
106
|
-
listViewToggleElement={ listViewToggleElement }
|
|
107
|
-
/>
|
|
108
|
-
)
|
|
109
|
-
}
|
|
97
|
+
header={ <Header /> }
|
|
98
|
+
secondarySidebar={ hasSecondarySidebar && <SecondarySidebar /> }
|
|
110
99
|
sidebar={
|
|
111
100
|
hasSidebarEnabled && (
|
|
112
101
|
<ComplementaryArea.Slot scope="core/edit-widgets" />
|
|
@@ -13,7 +13,7 @@ import { store as editWidgetsStore } from '../../store';
|
|
|
13
13
|
import InserterSidebar from './inserter-sidebar';
|
|
14
14
|
import ListViewSidebar from './list-view-sidebar';
|
|
15
15
|
|
|
16
|
-
export default function SecondarySidebar(
|
|
16
|
+
export default function SecondarySidebar() {
|
|
17
17
|
const { isInserterOpen, isListViewOpen } = useSelect( ( select ) => {
|
|
18
18
|
const { isInserterOpened, isListViewOpened } =
|
|
19
19
|
select( editWidgetsStore );
|
|
@@ -27,9 +27,7 @@ export default function SecondarySidebar( { listViewToggleElement } ) {
|
|
|
27
27
|
return <InserterSidebar />;
|
|
28
28
|
}
|
|
29
29
|
if ( isListViewOpen ) {
|
|
30
|
-
return
|
|
31
|
-
<ListViewSidebar listViewToggleElement={ listViewToggleElement } />
|
|
32
|
-
);
|
|
30
|
+
return <ListViewSidebar />;
|
|
33
31
|
}
|
|
34
32
|
return null;
|
|
35
33
|
}
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
import { __experimentalListView as ListView } from '@wordpress/block-editor';
|
|
5
5
|
import { Button } from '@wordpress/components';
|
|
6
6
|
import { useFocusOnMount, useMergeRefs } from '@wordpress/compose';
|
|
7
|
-
import { useDispatch } from '@wordpress/data';
|
|
7
|
+
import { useDispatch, useSelect } from '@wordpress/data';
|
|
8
8
|
import { useCallback, useState } from '@wordpress/element';
|
|
9
9
|
import { __ } from '@wordpress/i18n';
|
|
10
10
|
import { closeSmall } from '@wordpress/icons';
|
|
@@ -14,9 +14,11 @@ import { ESCAPE } from '@wordpress/keycodes';
|
|
|
14
14
|
* Internal dependencies
|
|
15
15
|
*/
|
|
16
16
|
import { store as editWidgetsStore } from '../../store';
|
|
17
|
+
import { unlock } from '../../lock-unlock';
|
|
17
18
|
|
|
18
|
-
export default function ListViewSidebar(
|
|
19
|
+
export default function ListViewSidebar() {
|
|
19
20
|
const { setIsListViewOpened } = useDispatch( editWidgetsStore );
|
|
21
|
+
const { getListViewToggleRef } = unlock( useSelect( editWidgetsStore ) );
|
|
20
22
|
|
|
21
23
|
// Use internal state instead of a ref to make sure that the component
|
|
22
24
|
// re-renders when the dropZoneElement updates.
|
|
@@ -27,8 +29,8 @@ export default function ListViewSidebar( { listViewToggleElement } ) {
|
|
|
27
29
|
// When closing the list view, focus should return to the toggle button.
|
|
28
30
|
const closeListView = useCallback( () => {
|
|
29
31
|
setIsListViewOpened( false );
|
|
30
|
-
|
|
31
|
-
}, [
|
|
32
|
+
getListViewToggleRef().current?.focus();
|
|
33
|
+
}, [ getListViewToggleRef, setIsListViewOpened ] );
|
|
32
34
|
|
|
33
35
|
const closeOnEscape = useCallback(
|
|
34
36
|
( event ) => {
|
package/src/store/index.js
CHANGED
|
@@ -11,7 +11,9 @@ import reducer from './reducer';
|
|
|
11
11
|
import * as resolvers from './resolvers';
|
|
12
12
|
import * as selectors from './selectors';
|
|
13
13
|
import * as actions from './actions';
|
|
14
|
+
import * as privateSelectors from './private-selectors';
|
|
14
15
|
import { STORE_NAME } from './constants';
|
|
16
|
+
import { unlock } from '../lock-unlock';
|
|
15
17
|
|
|
16
18
|
/**
|
|
17
19
|
* Block editor data store configuration.
|
|
@@ -47,3 +49,5 @@ apiFetch.use( function ( options, next ) {
|
|
|
47
49
|
|
|
48
50
|
return next( options );
|
|
49
51
|
} );
|
|
52
|
+
|
|
53
|
+
unlock( store ).registerPrivateSelectors( privateSelectors );
|
package/src/store/reducer.js
CHANGED
|
@@ -68,6 +68,17 @@ export function listViewPanel( state = false, action ) {
|
|
|
68
68
|
return state;
|
|
69
69
|
}
|
|
70
70
|
|
|
71
|
+
/**
|
|
72
|
+
* This reducer does nothing aside initializing a ref to the list view toggle.
|
|
73
|
+
* We will have a unique ref per "editor" instance.
|
|
74
|
+
*
|
|
75
|
+
* @param {Object} state
|
|
76
|
+
* @return {Object} Reference to the list view toggle button.
|
|
77
|
+
*/
|
|
78
|
+
export function listViewToggleRef( state = { current: null } ) {
|
|
79
|
+
return state;
|
|
80
|
+
}
|
|
81
|
+
|
|
71
82
|
export default combineReducers( {
|
|
72
83
|
blockInserterPanel,
|
|
73
84
|
listViewPanel,
|