@wordpress/edit-widgets 7.2.0 → 7.3.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.
Files changed (187) hide show
  1. package/build/blocks/widget-area/edit/index.cjs +10 -8
  2. package/build/blocks/widget-area/edit/index.cjs.map +1 -1
  3. package/build/blocks/widget-area/edit/inner-blocks.cjs +10 -8
  4. package/build/blocks/widget-area/edit/inner-blocks.cjs.map +1 -1
  5. package/build/blocks/widget-area/edit/use-is-dragging-within.cjs.map +1 -1
  6. package/build/blocks/widget-area/index.cjs +9 -7
  7. package/build/blocks/widget-area/index.cjs.map +1 -1
  8. package/build/components/error-boundary/index.cjs.map +1 -1
  9. package/build/components/header/document-tools/index.cjs +20 -10
  10. package/build/components/header/document-tools/index.cjs.map +1 -1
  11. package/build/components/header/index.cjs +12 -10
  12. package/build/components/header/index.cjs.map +1 -1
  13. package/build/components/keyboard-shortcut-help-modal/config.cjs +5 -0
  14. package/build/components/keyboard-shortcut-help-modal/config.cjs.map +1 -1
  15. package/build/components/keyboard-shortcut-help-modal/dynamic-shortcut.cjs +9 -7
  16. package/build/components/keyboard-shortcut-help-modal/dynamic-shortcut.cjs.map +1 -1
  17. package/build/components/keyboard-shortcut-help-modal/index.cjs +12 -11
  18. package/build/components/keyboard-shortcut-help-modal/index.cjs.map +1 -1
  19. package/build/components/keyboard-shortcut-help-modal/shortcut.cjs +34 -13
  20. package/build/components/keyboard-shortcut-help-modal/shortcut.cjs.map +1 -1
  21. package/build/components/keyboard-shortcuts/index.cjs.map +1 -1
  22. package/build/components/layout/index.cjs +19 -13
  23. package/build/components/layout/index.cjs.map +1 -1
  24. package/build/components/layout/interface.cjs +27 -13
  25. package/build/components/layout/interface.cjs.map +1 -1
  26. package/build/components/layout/unsaved-changes-warning.cjs.map +1 -1
  27. package/build/components/more-menu/index.cjs +14 -9
  28. package/build/components/more-menu/index.cjs.map +1 -1
  29. package/build/components/secondary-sidebar/index.cjs +10 -8
  30. package/build/components/secondary-sidebar/index.cjs.map +1 -1
  31. package/build/components/secondary-sidebar/inserter-sidebar.cjs +9 -7
  32. package/build/components/secondary-sidebar/inserter-sidebar.cjs.map +1 -1
  33. package/build/components/sidebar/index.cjs +23 -15
  34. package/build/components/sidebar/index.cjs.map +1 -1
  35. package/build/components/welcome-guide/index.cjs +5 -1
  36. package/build/components/welcome-guide/index.cjs.map +1 -1
  37. package/build/components/widget-areas-block-editor-content/index.cjs +10 -8
  38. package/build/components/widget-areas-block-editor-content/index.cjs.map +1 -1
  39. package/build/components/widget-areas-block-editor-provider/index.cjs +10 -8
  40. package/build/components/widget-areas-block-editor-provider/index.cjs.map +1 -1
  41. package/build/constants.cjs +0 -2
  42. package/build/constants.cjs.map +1 -1
  43. package/build/index.cjs +12 -10
  44. package/build/index.cjs.map +1 -1
  45. package/build/store/actions.cjs +11 -7
  46. package/build/store/actions.cjs.map +1 -1
  47. package/build/store/index.cjs +14 -12
  48. package/build/store/index.cjs.map +1 -1
  49. package/build/store/selectors.cjs +3 -1
  50. package/build/store/selectors.cjs.map +1 -1
  51. package/build-module/blocks/widget-area/index.mjs.map +1 -1
  52. package/build-module/components/header/document-tools/index.mjs +10 -2
  53. package/build-module/components/header/document-tools/index.mjs.map +1 -1
  54. package/build-module/components/header/undo-redo/redo.mjs.map +1 -1
  55. package/build-module/components/header/undo-redo/undo.mjs.map +1 -1
  56. package/build-module/components/keyboard-shortcut-help-modal/config.mjs +5 -0
  57. package/build-module/components/keyboard-shortcut-help-modal/config.mjs.map +1 -1
  58. package/build-module/components/keyboard-shortcut-help-modal/index.mjs +1 -2
  59. package/build-module/components/keyboard-shortcut-help-modal/index.mjs.map +1 -1
  60. package/build-module/components/keyboard-shortcut-help-modal/shortcut.mjs +34 -13
  61. package/build-module/components/keyboard-shortcut-help-modal/shortcut.mjs.map +1 -1
  62. package/build-module/components/layout/index.mjs +5 -1
  63. package/build-module/components/layout/index.mjs.map +1 -1
  64. package/build-module/components/layout/interface.mjs +16 -4
  65. package/build-module/components/layout/interface.mjs.map +1 -1
  66. package/build-module/components/more-menu/index.mjs +4 -1
  67. package/build-module/components/more-menu/index.mjs.map +1 -1
  68. package/build-module/components/sidebar/index.mjs +14 -8
  69. package/build-module/components/sidebar/index.mjs.map +1 -1
  70. package/build-module/components/welcome-guide/index.mjs +5 -1
  71. package/build-module/components/welcome-guide/index.mjs.map +1 -1
  72. package/build-module/constants.mjs +1 -2
  73. package/build-module/constants.mjs.map +1 -1
  74. package/build-module/index.mjs +2 -2
  75. package/build-module/index.mjs.map +1 -1
  76. package/build-module/store/actions.mjs +11 -7
  77. package/build-module/store/actions.mjs.map +1 -1
  78. package/build-module/store/selectors.mjs +3 -1
  79. package/build-module/store/selectors.mjs.map +1 -1
  80. package/build-style/style-rtl.css +42 -37
  81. package/build-style/style.css +42 -37
  82. package/build-types/blocks/widget-area/edit/index.d.ts +10 -0
  83. package/build-types/blocks/widget-area/edit/index.d.ts.map +1 -0
  84. package/build-types/blocks/widget-area/edit/inner-blocks.d.ts +4 -0
  85. package/build-types/blocks/widget-area/edit/inner-blocks.d.ts.map +1 -0
  86. package/build-types/blocks/widget-area/edit/use-is-dragging-within.d.ts +12 -0
  87. package/build-types/blocks/widget-area/edit/use-is-dragging-within.d.ts.map +1 -0
  88. package/build-types/blocks/widget-area/index.d.ts +14 -0
  89. package/build-types/blocks/widget-area/index.d.ts.map +1 -0
  90. package/build-types/components/error-boundary/index.d.ts +14 -0
  91. package/build-types/components/error-boundary/index.d.ts.map +1 -0
  92. package/build-types/components/header/document-tools/index.d.ts +3 -0
  93. package/build-types/components/header/document-tools/index.d.ts.map +1 -0
  94. package/build-types/components/header/index.d.ts +3 -0
  95. package/build-types/components/header/index.d.ts.map +1 -0
  96. package/build-types/components/header/undo-redo/redo.d.ts +3 -0
  97. package/build-types/components/header/undo-redo/redo.d.ts.map +1 -0
  98. package/build-types/components/header/undo-redo/undo.d.ts +3 -0
  99. package/build-types/components/header/undo-redo/undo.d.ts.map +1 -0
  100. package/build-types/components/keyboard-shortcut-help-modal/config.d.ts +3 -0
  101. package/build-types/components/keyboard-shortcut-help-modal/config.d.ts.map +1 -0
  102. package/build-types/components/keyboard-shortcut-help-modal/dynamic-shortcut.d.ts +5 -0
  103. package/build-types/components/keyboard-shortcut-help-modal/dynamic-shortcut.d.ts.map +1 -0
  104. package/build-types/components/keyboard-shortcut-help-modal/index.d.ts +5 -0
  105. package/build-types/components/keyboard-shortcut-help-modal/index.d.ts.map +1 -0
  106. package/build-types/components/keyboard-shortcut-help-modal/shortcut.d.ts +25 -0
  107. package/build-types/components/keyboard-shortcut-help-modal/shortcut.d.ts.map +1 -0
  108. package/build-types/components/keyboard-shortcuts/index.d.ts +7 -0
  109. package/build-types/components/keyboard-shortcuts/index.d.ts.map +1 -0
  110. package/build-types/components/layout/index.d.ts +5 -0
  111. package/build-types/components/layout/index.d.ts.map +1 -0
  112. package/build-types/components/layout/interface.d.ts +5 -0
  113. package/build-types/components/layout/interface.d.ts.map +1 -0
  114. package/build-types/components/layout/unsaved-changes-warning.d.ts +10 -0
  115. package/build-types/components/layout/unsaved-changes-warning.d.ts.map +1 -0
  116. package/build-types/components/more-menu/index.d.ts +2 -0
  117. package/build-types/components/more-menu/index.d.ts.map +1 -0
  118. package/build-types/components/more-menu/tools-more-menu-group.d.ts +6 -0
  119. package/build-types/components/more-menu/tools-more-menu-group.d.ts.map +1 -0
  120. package/build-types/components/notices/index.d.ts +3 -0
  121. package/build-types/components/notices/index.d.ts.map +1 -0
  122. package/build-types/components/save-button/index.d.ts +3 -0
  123. package/build-types/components/save-button/index.d.ts.map +1 -0
  124. package/build-types/components/secondary-sidebar/index.d.ts +2 -0
  125. package/build-types/components/secondary-sidebar/index.d.ts.map +1 -0
  126. package/build-types/components/secondary-sidebar/inserter-sidebar.d.ts +2 -0
  127. package/build-types/components/secondary-sidebar/inserter-sidebar.d.ts.map +1 -0
  128. package/build-types/components/secondary-sidebar/list-view-sidebar.d.ts +2 -0
  129. package/build-types/components/secondary-sidebar/list-view-sidebar.d.ts.map +1 -0
  130. package/build-types/components/sidebar/index.d.ts +2 -0
  131. package/build-types/components/sidebar/index.d.ts.map +1 -0
  132. package/build-types/components/sidebar/widget-areas.d.ts +4 -0
  133. package/build-types/components/sidebar/widget-areas.d.ts.map +1 -0
  134. package/build-types/components/welcome-guide/index.d.ts +2 -0
  135. package/build-types/components/welcome-guide/index.d.ts.map +1 -0
  136. package/build-types/components/widget-areas-block-editor-content/index.d.ts +4 -0
  137. package/build-types/components/widget-areas-block-editor-content/index.d.ts.map +1 -0
  138. package/build-types/components/widget-areas-block-editor-provider/index.d.ts +6 -0
  139. package/build-types/components/widget-areas-block-editor-provider/index.d.ts.map +1 -0
  140. package/build-types/constants.d.ts +2 -0
  141. package/build-types/constants.d.ts.map +1 -0
  142. package/build-types/filters/index.d.ts +3 -0
  143. package/build-types/filters/index.d.ts.map +1 -0
  144. package/build-types/filters/move-to-widget-area.d.ts +2 -0
  145. package/build-types/filters/move-to-widget-area.d.ts.map +1 -0
  146. package/build-types/filters/replace-media-upload.d.ts +2 -0
  147. package/build-types/filters/replace-media-upload.d.ts.map +1 -0
  148. package/build-types/hooks/use-last-selected-widget-area.d.ts +9 -0
  149. package/build-types/hooks/use-last-selected-widget-area.d.ts.map +1 -0
  150. package/build-types/hooks/use-widget-library-insertion-point.d.ts +3 -0
  151. package/build-types/hooks/use-widget-library-insertion-point.d.ts.map +1 -0
  152. package/build-types/index.d.ts +16 -0
  153. package/build-types/index.d.ts.map +1 -0
  154. package/build-types/lock-unlock.d.ts +2 -0
  155. package/build-types/lock-unlock.d.ts.map +1 -0
  156. package/build-types/store/actions.d.ts +144 -0
  157. package/build-types/store/actions.d.ts.map +1 -0
  158. package/build-types/store/constants.d.ts +5 -0
  159. package/build-types/store/constants.d.ts.map +1 -0
  160. package/build-types/store/index.d.ts +9 -0
  161. package/build-types/store/index.d.ts.map +1 -0
  162. package/build-types/store/private-selectors.d.ts +3 -0
  163. package/build-types/store/private-selectors.d.ts.map +1 -0
  164. package/build-types/store/reducer.d.ts +73 -0
  165. package/build-types/store/reducer.d.ts.map +1 -0
  166. package/build-types/store/resolvers.d.ts +17 -0
  167. package/build-types/store/resolvers.d.ts.map +1 -0
  168. package/build-types/store/selectors.d.ts +159 -0
  169. package/build-types/store/selectors.d.ts.map +1 -0
  170. package/build-types/store/transformers.d.ts +16 -0
  171. package/build-types/store/transformers.d.ts.map +1 -0
  172. package/build-types/store/utils.d.ts +53 -0
  173. package/build-types/store/utils.d.ts.map +1 -0
  174. package/package.json +33 -33
  175. package/src/components/header/style.scss +1 -1
  176. package/src/components/keyboard-shortcut-help-modal/config.js +3 -0
  177. package/src/components/keyboard-shortcut-help-modal/index.jsx +0 -2
  178. package/src/components/keyboard-shortcut-help-modal/shortcut.jsx +43 -29
  179. package/src/components/sidebar/index.jsx +1 -1
  180. package/src/components/sidebar/style.scss +6 -0
  181. package/src/components/welcome-guide/style.scss +1 -1
  182. package/src/components/widget-areas-block-editor-content/style.scss +1 -1
  183. package/src/constants.js +0 -1
  184. package/src/index.jsx +2 -7
  185. package/src/store/actions.js +8 -12
  186. package/src/store/selectors.js +4 -1
  187. package/src/store/test/actions.jsdom.test.js +47 -2
@@ -145,7 +145,7 @@
145
145
  }
146
146
 
147
147
  @media (forced-colors: active) {
148
- background: SelectedItem !important;
148
+ background: Highlight !important;
149
149
 
150
150
  &:disabled,
151
151
  &[aria-disabled="true"] {
@@ -1,5 +1,6 @@
1
1
  import { __ } from '@wordpress/i18n';
2
2
 
3
+ /** @type {Array<import('react').ComponentProps<typeof import('./shortcut').default>>} */
3
4
  export const textFormattingShortcuts = [
4
5
  {
5
6
  keyCombination: { modifier: 'primary', character: 'b' },
@@ -19,6 +20,8 @@ export const textFormattingShortcuts = [
19
20
  },
20
21
  {
21
22
  keyCombination: { character: '[[' },
23
+ /* translators: The keyboard sequence [[, pressing the left bracket key twice. */
24
+ ariaLabel: __( 'Left bracket twice' ),
22
25
  description: __( 'Insert a link to a post or page.' ),
23
26
  },
24
27
  {
@@ -115,8 +115,6 @@ export default function KeyboardShortcutHelpModal( {
115
115
  description: __(
116
116
  'Change the block type after adding a new paragraph.'
117
117
  ),
118
- /* translators: The forward-slash character. e.g. '/'. */
119
- ariaLabel: __( 'Forward-slash' ),
120
118
  },
121
119
  ] }
122
120
  />
@@ -1,43 +1,57 @@
1
1
  import { Fragment } from '@wordpress/element';
2
2
  import { displayShortcutList, shortcutAriaLabel } from '@wordpress/keycodes';
3
+ import { VisuallyHidden } from '@wordpress/ui';
3
4
 
4
- function KeyCombination( { keyCombination, forceAriaLabel } ) {
5
- const shortcut = keyCombination.modifier
6
- ? displayShortcutList[ keyCombination.modifier ](
7
- keyCombination.character
8
- )
9
- : keyCombination.character;
10
- const ariaLabel = keyCombination.modifier
11
- ? shortcutAriaLabel[ keyCombination.modifier ](
12
- keyCombination.character
13
- )
14
- : keyCombination.character;
15
- const shortcuts = Array.isArray( shortcut ) ? shortcut : [ shortcut ];
5
+ /**
6
+ * @typedef {Object} ShortcutKeyCombination
7
+ * @property {string} character Shortcut key.
8
+ * @property {import('@wordpress/keycodes').WPKeycodeModifier | null} [modifier] Optional shortcut modifier.
9
+ */
10
+
11
+ /**
12
+ * @param {Object} props Component props.
13
+ * @param {ShortcutKeyCombination} props.keyCombination Shortcut to display.
14
+ * @param {string} [props.ariaLabel] Custom readable shortcut label.
15
+ */
16
+ function KeyCombination( { keyCombination, ariaLabel } ) {
17
+ const { character, modifier } = keyCombination;
18
+ const normalizedModifier = modifier ?? 'undefined';
19
+ const keys = displayShortcutList[ normalizedModifier ]( character );
16
20
 
17
21
  return (
18
22
  <kbd
19
23
  className="edit-widgets-keyboard-shortcut-help-modal__shortcut-key-combination"
20
24
  dir="ltr"
21
- aria-label={ forceAriaLabel || ariaLabel }
22
25
  >
23
- { shortcuts.map( ( character, index ) => {
24
- if ( character === '+' ) {
25
- return <Fragment key={ index }>{ character }</Fragment>;
26
- }
27
-
28
- return (
29
- <kbd
30
- key={ index }
31
- className="edit-widgets-keyboard-shortcut-help-modal__shortcut-key"
32
- >
33
- { character }
34
- </kbd>
35
- );
36
- } ) }
26
+ <VisuallyHidden render={ <span /> }>
27
+ { ariaLabel ||
28
+ shortcutAriaLabel[ normalizedModifier ]( character ) }
29
+ </VisuallyHidden>
30
+ <span aria-hidden="true">
31
+ { keys.map( ( key, index ) =>
32
+ key === '+' && index < keys.length - 1 ? (
33
+ <Fragment key={ index }>{ key }</Fragment>
34
+ ) : (
35
+ <kbd
36
+ key={ index }
37
+ className="edit-widgets-keyboard-shortcut-help-modal__shortcut-key"
38
+ >
39
+ { key }
40
+ </kbd>
41
+ )
42
+ ) }
43
+ </span>
37
44
  </kbd>
38
45
  );
39
46
  }
40
47
 
48
+ /**
49
+ * @param {Object} props Component props.
50
+ * @param {string} props.description Description of the shortcut action.
51
+ * @param {ShortcutKeyCombination} props.keyCombination Primary shortcut.
52
+ * @param {ShortcutKeyCombination[]} [props.aliases] Alternative shortcuts.
53
+ * @param {string} [props.ariaLabel] Custom readable shortcut label.
54
+ */
41
55
  function Shortcut( { description, keyCombination, aliases = [], ariaLabel } ) {
42
56
  return (
43
57
  <>
@@ -47,12 +61,12 @@ function Shortcut( { description, keyCombination, aliases = [], ariaLabel } ) {
47
61
  <div className="edit-widgets-keyboard-shortcut-help-modal__shortcut-term">
48
62
  <KeyCombination
49
63
  keyCombination={ keyCombination }
50
- forceAriaLabel={ ariaLabel }
64
+ ariaLabel={ ariaLabel }
51
65
  />
52
66
  { aliases.map( ( alias, index ) => (
53
67
  <KeyCombination
54
68
  keyCombination={ alias }
55
- forceAriaLabel={ ariaLabel }
69
+ ariaLabel={ ariaLabel }
56
70
  key={ index }
57
71
  />
58
72
  ) ) }
@@ -24,7 +24,7 @@ const { Tabs: WCTabs } = unlock( componentsPrivateApis );
24
24
 
25
25
  function SidebarHeader( { selectedWidgetAreaBlock } ) {
26
26
  return (
27
- <WCTabs.TabList>
27
+ <WCTabs.TabList className="edit-widgets-sidebar__panel-tablist">
28
28
  <WCTabs.Tab tabId={ WIDGET_AREAS_IDENTIFIER }>
29
29
  { selectedWidgetAreaBlock
30
30
  ? selectedWidgetAreaBlock.attributes.name
@@ -4,6 +4,12 @@
4
4
  padding-left: 0;
5
5
  }
6
6
 
7
+ // Overlap the header's bottom border, so the selected tab's indicator
8
+ // covers it, as in the inserter.
9
+ .edit-widgets-sidebar__panel-tablist {
10
+ margin-bottom: -$border-width;
11
+ }
12
+
7
13
 
8
14
  .edit-widgets-widget-areas__top-container {
9
15
  display: flex;
@@ -23,7 +23,7 @@
23
23
  }
24
24
 
25
25
  &__text {
26
- font-size: $default-font-size;
26
+ font-size: var(--wpds-typography-font-size-md);
27
27
  line-height: 1.4;
28
28
  margin: 0 0 $grid-unit-30 0;
29
29
  padding: 0 $grid-unit-40;
@@ -28,7 +28,7 @@
28
28
  // This is copied from edit-post/src/components/style.scss but without the padding.
29
29
  & .components-button {
30
30
  font-family: $default-font;
31
- font-size: $default-font-size;
31
+ font-size: var(--wpds-typography-font-size-md);
32
32
 
33
33
  &.is-tertiary,
34
34
  &.has-icon {
package/src/constants.js CHANGED
@@ -1,2 +1 @@
1
1
  export const ALLOW_REUSABLE_BLOCKS = false;
2
- export const ENABLE_EXPERIMENTAL_FSE_BLOCKS = false;
package/src/index.jsx CHANGED
@@ -23,10 +23,7 @@ import './store';
23
23
  import './filters';
24
24
  import * as widgetArea from './blocks/widget-area';
25
25
  import Layout from './components/layout';
26
- import {
27
- ALLOW_REUSABLE_BLOCKS,
28
- ENABLE_EXPERIMENTAL_FSE_BLOCKS,
29
- } from './constants';
26
+ import { ALLOW_REUSABLE_BLOCKS } from './constants';
30
27
 
31
28
  const disabledBlocks = [
32
29
  'core/more',
@@ -67,9 +64,7 @@ export function initializeEditor( id, settings ) {
67
64
  registerCoreBlocks( coreBlocks );
68
65
  registerLegacyWidgetBlock();
69
66
  if ( globalThis.IS_GUTENBERG_PLUGIN ) {
70
- __experimentalRegisterExperimentalCoreBlocks( {
71
- enableFSEBlocks: ENABLE_EXPERIMENTAL_FSE_BLOCKS,
72
- } );
67
+ __experimentalRegisterExperimentalCoreBlocks();
73
68
  }
74
69
  registerLegacyWidgetVariations( settings );
75
70
  registerBlock( widgetArea );
@@ -108,7 +108,7 @@ export const saveWidgetAreas =
108
108
  */
109
109
  export const saveWidgetArea =
110
110
  ( widgetAreaId ) =>
111
- async ( { dispatch, select, registry } ) => {
111
+ async ( { select, registry } ) => {
112
112
  const widgets = select.getWidgets();
113
113
 
114
114
  const post = registry
@@ -287,17 +287,9 @@ export const saveWidgetArea =
287
287
  { undoIgnore: true }
288
288
  );
289
289
 
290
- dispatch( trySaveWidgetArea( widgetAreaId ) );
291
-
292
- registry
293
- .dispatch( coreStore )
294
- .receiveEntityRecords( KIND, POST_TYPE, post, undefined );
295
- };
296
-
297
- const trySaveWidgetArea =
298
- ( widgetAreaId ) =>
299
- ( { registry } ) => {
300
- registry
290
+ // Sidebar and widget requests can both rewrite the sidebar lists. Finish
291
+ // this write before saveWidgetAreas starts saving the next area.
292
+ await registry
301
293
  .dispatch( coreStore )
302
294
  .saveEditedEntityRecord(
303
295
  KIND,
@@ -307,6 +299,10 @@ const trySaveWidgetArea =
307
299
  throwOnError: true,
308
300
  }
309
301
  );
302
+
303
+ registry
304
+ .dispatch( coreStore )
305
+ .receiveEntityRecords( KIND, POST_TYPE, post, undefined );
310
306
  };
311
307
 
312
308
  /**
@@ -12,6 +12,8 @@ import {
12
12
  } from './utils';
13
13
  import { STORE_NAME as editWidgetsStoreName } from './constants';
14
14
 
15
+ /** @typedef {import('@wordpress/blocks').Block} Block */
16
+
15
17
  const EMPTY_INSERTION_POINT = {
16
18
  rootClientId: undefined,
17
19
  insertionIndex: undefined,
@@ -108,7 +110,8 @@ export const getWidgetAreaForWidgetId = createRegistrySelector(
108
110
  *
109
111
  * @param {string} clientId The client id of a block in a widget area.
110
112
  *
111
- * @return {WPBlock} The widget area block.
113
+ * @return {Block | null} The widget area block.
114
+ * @type {(state: Record<string, unknown>, clientId: string) => Block | null}
112
115
  */
113
116
  export const getParentWidgetAreaBlock = createRegistrySelector(
114
117
  ( select ) => ( state, clientId ) => {
@@ -1,5 +1,5 @@
1
1
  import { describe, expect, it, vi } from 'vitest';
2
- import { saveWidgetArea } from '../actions';
2
+ import { saveWidgetArea, saveWidgetAreas } from '../actions';
3
3
 
4
4
  // Only the store descriptors are imported from these packages; stub them so
5
5
  // their browser-only side effects do not run.
@@ -57,7 +57,6 @@ function setup(
57
57
  return {
58
58
  run: () =>
59
59
  saveWidgetArea( area )( {
60
- dispatch: vi.fn(),
61
60
  select,
62
61
  registry,
63
62
  } ),
@@ -67,6 +66,52 @@ function setup(
67
66
  };
68
67
  }
69
68
 
69
+ describe( 'saveWidgetAreas', () => {
70
+ it( 'waits for a widget area’s sidebar save before saving the next area', async () => {
71
+ const firstSidebarSave = Promise.withResolvers();
72
+ const saveSidebar = vi.fn( ( kind, name, id ) =>
73
+ id === 'sidebar-1' ? firstSidebarSave.promise : Promise.resolve()
74
+ );
75
+ const registry = {
76
+ select: () => ( {
77
+ getEditedEntityRecord: () => ( { blocks: [] } ),
78
+ } ),
79
+ dispatch: () => ( {
80
+ __experimentalBatch: async () => [],
81
+ editEntityRecord: vi.fn(),
82
+ finishResolution: vi.fn(),
83
+ receiveEntityRecords: vi.fn(),
84
+ saveEditedEntityRecord: saveSidebar,
85
+ } ),
86
+ };
87
+ const select = { getWidgets: () => ( {} ) };
88
+ const dispatch = Object.assign(
89
+ ( thunk ) => thunk( { registry, select, dispatch } ),
90
+ {
91
+ saveWidgetArea: vi.fn( ( id ) =>
92
+ dispatch( saveWidgetArea( id ) )
93
+ ),
94
+ }
95
+ );
96
+ const save = dispatch(
97
+ saveWidgetAreas( [ { id: 'sidebar-1' }, { id: 'sidebar-2' } ] )
98
+ );
99
+ try {
100
+ await vi.waitFor( () => expect( saveSidebar ).toHaveBeenCalled() );
101
+ expect( dispatch.saveWidgetArea.mock.calls ).toEqual( [
102
+ [ 'sidebar-1' ],
103
+ ] );
104
+ } finally {
105
+ firstSidebarSave.resolve();
106
+ await save;
107
+ }
108
+ expect( saveSidebar.mock.calls.map( ( [ , , id ] ) => id ) ).toEqual( [
109
+ 'sidebar-1',
110
+ 'sidebar-2',
111
+ ] );
112
+ } );
113
+ } );
114
+
70
115
  describe( 'saveWidgetArea', () => {
71
116
  it( 'saves a block that shares an existing widget ID with an earlier block as a new widget', async () => {
72
117
  // Splitting a paragraph widget copies the block's attributes,