@wordpress/block-library 8.3.2 → 8.4.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 (193) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/build/button/edit.js +3 -1
  3. package/build/button/edit.js.map +1 -1
  4. package/build/button/index.js +17 -6
  5. package/build/button/index.js.map +1 -1
  6. package/build/cover/edit/index.js +3 -2
  7. package/build/cover/edit/index.js.map +1 -1
  8. package/build/file/index.js +10 -1
  9. package/build/file/index.js.map +1 -1
  10. package/build/image/image.js +21 -15
  11. package/build/image/image.js.map +1 -1
  12. package/build/latest-comments/edit.js +6 -2
  13. package/build/latest-comments/edit.js.map +1 -1
  14. package/build/latest-comments/index.js +13 -0
  15. package/build/latest-comments/index.js.map +1 -1
  16. package/build/navigation/edit/index.js +2 -28
  17. package/build/navigation/edit/index.js.map +1 -1
  18. package/build/navigation/edit/menu-inspector-controls.js +5 -6
  19. package/build/navigation/edit/menu-inspector-controls.js.map +1 -1
  20. package/build/navigation/edit/navigation-menu-selector.js +14 -11
  21. package/build/navigation/edit/navigation-menu-selector.js.map +1 -1
  22. package/build/navigation/edit/unsaved-inner-blocks.js +4 -5
  23. package/build/navigation/edit/unsaved-inner-blocks.js.map +1 -1
  24. package/build/navigation/edit/use-create-navigation-menu.js +11 -2
  25. package/build/navigation/edit/use-create-navigation-menu.js.map +1 -1
  26. package/build/navigation/use-navigation-menu.js +1 -1
  27. package/build/navigation/use-navigation-menu.js.map +1 -1
  28. package/build/navigation-link/edit.js +4 -0
  29. package/build/navigation-link/edit.js.map +1 -1
  30. package/build/navigation-link/link-ui.js +1 -0
  31. package/build/navigation-link/link-ui.js.map +1 -1
  32. package/build/navigation-submenu/edit.js +4 -0
  33. package/build/navigation-submenu/edit.js.map +1 -1
  34. package/build/page-list/edit.js +5 -4
  35. package/build/page-list/edit.js.map +1 -1
  36. package/build/page-list/use-convert-to-navigation-links.js +61 -5
  37. package/build/page-list/use-convert-to-navigation-links.js.map +1 -1
  38. package/build/post-excerpt/edit.js +49 -3
  39. package/build/post-excerpt/edit.js.map +1 -1
  40. package/build/post-excerpt/index.js +4 -0
  41. package/build/post-excerpt/index.js.map +1 -1
  42. package/build/post-featured-image/dimension-controls.js +52 -1
  43. package/build/post-featured-image/dimension-controls.js.map +1 -1
  44. package/build/post-featured-image/edit.js +9 -4
  45. package/build/post-featured-image/edit.js.map +1 -1
  46. package/build/post-featured-image/index.js +3 -0
  47. package/build/post-featured-image/index.js.map +1 -1
  48. package/build/{experiments.js → private-apis.js} +3 -3
  49. package/build/private-apis.js.map +1 -0
  50. package/build/site-logo/edit.js +7 -11
  51. package/build/site-logo/edit.js.map +1 -1
  52. package/build/table/edit.js +3 -3
  53. package/build/table/edit.js.map +1 -1
  54. package/build/table-of-contents/utils.js +1 -1
  55. package/build/table-of-contents/utils.js.map +1 -1
  56. package/build/verse/index.js +6 -0
  57. package/build/verse/index.js.map +1 -1
  58. package/build-module/button/edit.js +2 -1
  59. package/build-module/button/edit.js.map +1 -1
  60. package/build-module/button/index.js +17 -6
  61. package/build-module/button/index.js.map +1 -1
  62. package/build-module/cover/edit/index.js +3 -2
  63. package/build-module/cover/edit/index.js.map +1 -1
  64. package/build-module/file/index.js +10 -1
  65. package/build-module/file/index.js.map +1 -1
  66. package/build-module/image/image.js +21 -15
  67. package/build-module/image/image.js.map +1 -1
  68. package/build-module/latest-comments/edit.js +6 -2
  69. package/build-module/latest-comments/edit.js.map +1 -1
  70. package/build-module/latest-comments/index.js +13 -0
  71. package/build-module/latest-comments/index.js.map +1 -1
  72. package/build-module/navigation/edit/index.js +3 -29
  73. package/build-module/navigation/edit/index.js.map +1 -1
  74. package/build-module/navigation/edit/menu-inspector-controls.js +5 -5
  75. package/build-module/navigation/edit/menu-inspector-controls.js.map +1 -1
  76. package/build-module/navigation/edit/navigation-menu-selector.js +14 -10
  77. package/build-module/navigation/edit/navigation-menu-selector.js.map +1 -1
  78. package/build-module/navigation/edit/unsaved-inner-blocks.js +4 -5
  79. package/build-module/navigation/edit/unsaved-inner-blocks.js.map +1 -1
  80. package/build-module/navigation/edit/use-create-navigation-menu.js +11 -2
  81. package/build-module/navigation/edit/use-create-navigation-menu.js.map +1 -1
  82. package/build-module/navigation/use-navigation-menu.js +1 -1
  83. package/build-module/navigation/use-navigation-menu.js.map +1 -1
  84. package/build-module/navigation-link/edit.js +4 -0
  85. package/build-module/navigation-link/edit.js.map +1 -1
  86. package/build-module/navigation-link/link-ui.js +1 -0
  87. package/build-module/navigation-link/link-ui.js.map +1 -1
  88. package/build-module/navigation-submenu/edit.js +4 -0
  89. package/build-module/navigation-submenu/edit.js.map +1 -1
  90. package/build-module/page-list/edit.js +5 -4
  91. package/build-module/page-list/edit.js.map +1 -1
  92. package/build-module/page-list/use-convert-to-navigation-links.js +61 -5
  93. package/build-module/page-list/use-convert-to-navigation-links.js.map +1 -1
  94. package/build-module/post-excerpt/edit.js +52 -5
  95. package/build-module/post-excerpt/edit.js.map +1 -1
  96. package/build-module/post-excerpt/index.js +4 -0
  97. package/build-module/post-excerpt/index.js.map +1 -1
  98. package/build-module/post-featured-image/dimension-controls.js +52 -1
  99. package/build-module/post-featured-image/dimension-controls.js.map +1 -1
  100. package/build-module/post-featured-image/edit.js +9 -4
  101. package/build-module/post-featured-image/edit.js.map +1 -1
  102. package/build-module/post-featured-image/index.js +3 -0
  103. package/build-module/post-featured-image/index.js.map +1 -1
  104. package/build-module/{experiments.js → private-apis.js} +2 -2
  105. package/build-module/private-apis.js.map +1 -0
  106. package/build-module/site-logo/edit.js +7 -11
  107. package/build-module/site-logo/edit.js.map +1 -1
  108. package/build-module/table/edit.js +3 -3
  109. package/build-module/table/edit.js.map +1 -1
  110. package/build-module/table-of-contents/utils.js +1 -1
  111. package/build-module/table-of-contents/utils.js.map +1 -1
  112. package/build-module/verse/index.js +6 -0
  113. package/build-module/verse/index.js.map +1 -1
  114. package/build-style/avatar/style-rtl.css +3 -0
  115. package/build-style/avatar/style.css +3 -0
  116. package/build-style/button/editor-rtl.css +31 -0
  117. package/build-style/button/editor.css +31 -0
  118. package/build-style/button/style-rtl.css +31 -0
  119. package/build-style/button/style.css +31 -0
  120. package/build-style/classic-rtl.css +5 -0
  121. package/build-style/classic.css +5 -0
  122. package/build-style/editor-rtl.css +36 -1
  123. package/build-style/editor.css +36 -1
  124. package/build-style/file/style-rtl.css +1 -0
  125. package/build-style/file/style.css +1 -0
  126. package/build-style/image/editor-rtl.css +1 -0
  127. package/build-style/image/editor.css +1 -0
  128. package/build-style/image/style-rtl.css +6 -2
  129. package/build-style/image/style.css +6 -0
  130. package/build-style/latest-comments/style-rtl.css +18 -5
  131. package/build-style/latest-comments/style.css +18 -5
  132. package/build-style/quote/style-rtl.css +5 -5
  133. package/build-style/quote/style.css +5 -5
  134. package/build-style/style-rtl.css +64 -12
  135. package/build-style/style.css +64 -10
  136. package/build-types/table-of-contents/utils.d.ts +1 -1
  137. package/package.json +30 -30
  138. package/src/avatar/index.php +67 -63
  139. package/src/avatar/style.scss +3 -0
  140. package/src/button/block.json +17 -6
  141. package/src/button/edit.js +2 -1
  142. package/src/button/editor.scss +36 -0
  143. package/src/button/style.scss +37 -1
  144. package/src/classic.scss +5 -0
  145. package/src/cover/edit/index.js +4 -1
  146. package/src/editor.scss +5 -0
  147. package/src/file/block.json +10 -1
  148. package/src/file/style.scss +1 -0
  149. package/src/image/editor.scss +1 -0
  150. package/src/image/image.js +32 -27
  151. package/src/image/style.scss +13 -0
  152. package/src/latest-comments/block.json +13 -0
  153. package/src/latest-comments/edit.js +9 -2
  154. package/src/latest-comments/style.scss +25 -7
  155. package/src/navigation/edit/index.js +1 -30
  156. package/src/navigation/edit/menu-inspector-controls.js +3 -4
  157. package/src/navigation/edit/navigation-menu-selector.js +12 -26
  158. package/src/navigation/edit/test/navigation-menu-selector.js +638 -0
  159. package/src/navigation/edit/unsaved-inner-blocks.js +29 -36
  160. package/src/navigation/edit/use-create-navigation-menu.js +13 -1
  161. package/src/navigation/index.php +8 -6
  162. package/src/navigation/use-navigation-menu.js +1 -1
  163. package/src/navigation-link/edit.js +3 -0
  164. package/src/navigation-link/link-ui.js +1 -0
  165. package/src/navigation-submenu/edit.js +3 -0
  166. package/src/page-list/edit.js +6 -5
  167. package/src/page-list/index.php +4 -4
  168. package/src/page-list/test/convert-to-links-modal.js +134 -0
  169. package/src/page-list/use-convert-to-navigation-links.js +64 -4
  170. package/src/post-excerpt/block.json +4 -0
  171. package/src/post-excerpt/edit.js +72 -7
  172. package/src/post-excerpt/index.php +29 -5
  173. package/src/post-featured-image/block.json +3 -0
  174. package/src/post-featured-image/dimension-controls.js +64 -2
  175. package/src/post-featured-image/edit.js +18 -6
  176. package/src/post-featured-image/index.php +25 -9
  177. package/src/post-title/index.php +3 -3
  178. package/src/{experiments.js → private-apis.js} +1 -1
  179. package/src/quote/style.scss +2 -2
  180. package/src/site-logo/edit.js +3 -6
  181. package/src/table/edit.js +3 -3
  182. package/src/table-of-contents/utils.ts +1 -1
  183. package/src/template-part/index.php +1 -1
  184. package/src/verse/block.json +6 -0
  185. package/tsconfig.json +24 -1
  186. package/tsconfig.tsbuildinfo +1 -1
  187. package/build/experiments.js.map +0 -1
  188. package/build/navigation/leaf-more-menu.js +0 -95
  189. package/build/navigation/leaf-more-menu.js.map +0 -1
  190. package/build-module/experiments.js.map +0 -1
  191. package/build-module/navigation/leaf-more-menu.js +0 -76
  192. package/build-module/navigation/leaf-more-menu.js.map +0 -1
  193. package/src/navigation/leaf-more-menu.js +0 -93
@@ -124,30 +124,31 @@ export default function Image( {
124
124
  },
125
125
  [ id, isSelected, clientId ]
126
126
  );
127
- const { canInsertCover, imageEditing, imageSizes, mediaUpload } = useSelect(
128
- ( select ) => {
129
- const { getBlockRootClientId, getSettings, canInsertBlockType } =
130
- select( blockEditorStore );
131
-
132
- const rootClientId = getBlockRootClientId( clientId );
133
- const settings = Object.fromEntries(
134
- Object.entries( getSettings() ).filter( ( [ key ] ) =>
135
- [ 'imageEditing', 'imageSizes', 'mediaUpload' ].includes(
136
- key
137
- )
138
- )
139
- );
140
-
141
- return {
142
- ...settings,
143
- canInsertCover: canInsertBlockType(
144
- 'core/cover',
145
- rootClientId
146
- ),
147
- };
148
- },
149
- [ clientId ]
150
- );
127
+ const { canInsertCover, imageEditing, imageSizes, maxWidth, mediaUpload } =
128
+ useSelect(
129
+ ( select ) => {
130
+ const {
131
+ getBlockRootClientId,
132
+ getSettings,
133
+ canInsertBlockType,
134
+ } = select( blockEditorStore );
135
+
136
+ const rootClientId = getBlockRootClientId( clientId );
137
+ const settings = getSettings();
138
+
139
+ return {
140
+ imageEditing: settings.imageEditing,
141
+ imageSizes: settings.imageSizes,
142
+ maxWidth: settings.maxWidth,
143
+ mediaUpload: settings.mediaUpload,
144
+ canInsertCover: canInsertBlockType(
145
+ 'core/cover',
146
+ rootClientId
147
+ ),
148
+ };
149
+ },
150
+ [ clientId ]
151
+ );
151
152
  const { replaceBlocks, toggleSelection } = useDispatch( blockEditorStore );
152
153
  const { createErrorNotice, createSuccessNotice } =
153
154
  useDispatch( noticesStore );
@@ -548,9 +549,13 @@ export default function Image( {
548
549
  // With the current implementation of ResizableBox, an image needs an
549
550
  // explicit pixel value for the max-width. In absence of being able to
550
551
  // set the content-width, this max-width is currently dictated by the
551
- // vanilla editor style. We'll use the clientWidth here, to prevent the width
552
- // of the image growing larger than the width of the block column.
553
- const maxWidthBuffer = clientWidth;
552
+ // vanilla editor style. The following variable adds a buffer to this
553
+ // vanilla style, so 3rd party themes have some wiggleroom. This does,
554
+ // in most cases, allow you to scale the image beyond the width of the
555
+ // main column, though not infinitely.
556
+ // @todo It would be good to revisit this once a content-width variable
557
+ // becomes available.
558
+ const maxWidthBuffer = maxWidth * 2.5;
554
559
 
555
560
  let showRightHandle = false;
556
561
  let showLeftHandle = false;
@@ -6,6 +6,17 @@
6
6
  box-sizing: border-box;
7
7
  }
8
8
 
9
+ // The following style maintains border radius application for deprecated
10
+ // image blocks that applied border radius to the outer `figure` element.
11
+ //
12
+ // See: https://github.com/WordPress/gutenberg/issues/47422
13
+ &[style*="border-radius"] {
14
+ > a,
15
+ img {
16
+ border-radius: inherit;
17
+ }
18
+ }
19
+
9
20
  &.has-custom-border {
10
21
  img {
11
22
  box-sizing: border-box;
@@ -41,6 +52,7 @@
41
52
  float: left;
42
53
  /*rtl:ignore*/
43
54
  margin-left: 0;
55
+ /*rtl:ignore*/
44
56
  margin-right: 1em;
45
57
  margin-top: 0.5em;
46
58
  margin-bottom: 0.5em;
@@ -51,6 +63,7 @@
51
63
  float: right;
52
64
  /*rtl:ignore*/
53
65
  margin-right: 0;
66
+ /*rtl:ignore*/
54
67
  margin-left: 1em;
55
68
  margin-top: 0.5em;
56
69
  margin-bottom: 0.5em;
@@ -34,6 +34,19 @@
34
34
  "spacing": {
35
35
  "margin": true,
36
36
  "padding": true
37
+ },
38
+ "typography": {
39
+ "fontSize": true,
40
+ "lineHeight": true,
41
+ "__experimentalFontFamily": true,
42
+ "__experimentalFontWeight": true,
43
+ "__experimentalFontStyle": true,
44
+ "__experimentalTextTransform": true,
45
+ "__experimentalTextDecoration": true,
46
+ "__experimentalLetterSpacing": true,
47
+ "__experimentalDefaultControls": {
48
+ "fontSize": true
49
+ }
37
50
  }
38
51
  },
39
52
  "editorStyle": "wp-block-latest-comments-editor",
@@ -28,6 +28,14 @@ export default function LatestComments( { attributes, setAttributes } ) {
28
28
  const { commentsToShow, displayAvatar, displayDate, displayExcerpt } =
29
29
  attributes;
30
30
 
31
+ const serverSideAttributes = {
32
+ ...attributes,
33
+ style: {
34
+ ...attributes?.style,
35
+ spacing: undefined,
36
+ },
37
+ };
38
+
31
39
  return (
32
40
  <div { ...useBlockProps() }>
33
41
  <InspectorControls>
@@ -71,8 +79,7 @@ export default function LatestComments( { attributes, setAttributes } ) {
71
79
  <Disabled>
72
80
  <ServerSideRender
73
81
  block="core/latest-comments"
74
- attributes={ attributes }
75
- skipBlockSupportAttributes
82
+ attributes={ serverSideAttributes }
76
83
  // The preview uses the site's locale to make it more true to how
77
84
  // the block appears on the frontend. Setting the locale
78
85
  // explicitly prevents any middleware from setting it to 'user'.
@@ -9,6 +9,23 @@ ol.wp-block-latest-comments {
9
9
  box-sizing: border-box;
10
10
  }
11
11
 
12
+ // Following styles leverage :where so that typography block support styles and
13
+ // global styles apply when necessary.
14
+ :where(.wp-block-latest-comments:not([style*="line-height"] .wp-block-latest-comments__comment)) {
15
+ line-height: 1.1;
16
+ }
17
+
18
+ :where(.wp-block-latest-comments:not([style*="line-height"] .wp-block-latest-comments__comment-excerpt p)) {
19
+ line-height: 1.8;
20
+ }
21
+
22
+ .has-dates,
23
+ .has-excerpts {
24
+ :where(.wp-block-latest-comments:not([style*="line-height"])) {
25
+ line-height: 1.5;
26
+ }
27
+ }
28
+
12
29
  // Higher specificity - target list via wrapper.
13
30
  .wp-block-latest-comments .wp-block-latest-comments {
14
31
  // Remove left spacing. Higher specificity required to
@@ -17,7 +34,6 @@ ol.wp-block-latest-comments {
17
34
  }
18
35
 
19
36
  .wp-block-latest-comments__comment {
20
- line-height: 1.1;
21
37
  list-style: none;
22
38
  margin-bottom: 1em;
23
39
 
@@ -30,16 +46,10 @@ ol.wp-block-latest-comments {
30
46
  margin-left: 3.25em;
31
47
  }
32
48
  }
33
-
34
- .has-dates &,
35
- .has-excerpts & {
36
- line-height: 1.5;
37
- }
38
49
  }
39
50
 
40
51
  .wp-block-latest-comments__comment-excerpt p {
41
52
  font-size: 0.875em;
42
- line-height: 1.8;
43
53
  margin: 0.36em 0 1.4em;
44
54
  }
45
55
 
@@ -57,3 +67,11 @@ ol.wp-block-latest-comments {
57
67
  margin-right: 0.75em;
58
68
  width: 2.5em;
59
69
  }
70
+
71
+ // Enforce font size when user has made selection at the individual block level.
72
+ .wp-block-latest-comments[style*="font-size"],
73
+ .wp-block-latest-comments[class*="-font-size"] {
74
+ a {
75
+ font-size: inherit;
76
+ }
77
+ }
@@ -27,7 +27,7 @@ import {
27
27
  __experimentalUseBlockOverlayActive as useBlockOverlayActive,
28
28
  __experimentalUseMultipleOriginColorsAndGradients as useMultipleOriginColorsAndGradients,
29
29
  } from '@wordpress/block-editor';
30
- import { EntityProvider, store as coreStore } from '@wordpress/core-data';
30
+ import { EntityProvider } from '@wordpress/core-data';
31
31
 
32
32
  import { useDispatch } from '@wordpress/data';
33
33
  import {
@@ -112,7 +112,6 @@ function Navigation( {
112
112
 
113
113
  const recursionId = `navigationMenu/${ ref }`;
114
114
  const hasAlreadyRendered = useHasRecursion( recursionId );
115
- const { editEntityRecord } = useDispatch( coreStore );
116
115
 
117
116
  // Preload classic menus, so that they don't suddenly pop-in when viewing
118
117
  // the Select Menu dropdown.
@@ -128,11 +127,6 @@ function Navigation( {
128
127
  name: 'block-library/core/navigation/classic-menu-conversion',
129
128
  } );
130
129
 
131
- const [ showMenuAutoPublishDraftNotice, hideMenuAutoPublishDraftNotice ] =
132
- useNavigationNotice( {
133
- name: 'block-library/core/navigation/auto-publish-draft',
134
- } );
135
-
136
130
  const [
137
131
  showNavigationMenuPermissionsNotice,
138
132
  hideNavigationMenuPermissionsNotice,
@@ -209,7 +203,6 @@ function Navigation( {
209
203
  isNavigationMenuResolved,
210
204
  isNavigationMenuMissing,
211
205
  navigationMenus,
212
- navigationMenu,
213
206
  canUserUpdateNavigationMenu,
214
207
  hasResolvedCanUserUpdateNavigationMenu,
215
208
  canUserDeleteNavigationMenu,
@@ -536,26 +529,6 @@ function Navigation( {
536
529
  { open: overlayMenuPreview }
537
530
  );
538
531
 
539
- // Prompt the user to publish the menu they have set as a draft
540
- const isDraftNavigationMenu = navigationMenu?.status === 'draft';
541
- useEffect( () => {
542
- hideMenuAutoPublishDraftNotice();
543
- if ( ! isDraftNavigationMenu ) {
544
- return;
545
- }
546
- editEntityRecord(
547
- 'postType',
548
- 'wp_navigation',
549
- navigationMenu?.id,
550
- { status: 'publish' },
551
- { throwOnError: true }
552
- ).catch( () => {
553
- showMenuAutoPublishDraftNotice(
554
- __( 'Error occurred while publishing the navigation menu.' )
555
- );
556
- } );
557
- }, [ isDraftNavigationMenu, navigationMenu ] );
558
-
559
532
  const colorGradientSettings = useMultipleOriginColorsAndGradients();
560
533
  const stylingInspectorControls = (
561
534
  <>
@@ -752,8 +725,6 @@ function Navigation( {
752
725
  <UnsavedInnerBlocks
753
726
  createNavigationMenu={ createNavigationMenu }
754
727
  blocks={ uncontrolledInnerBlocks }
755
- templateLock={ templateLock }
756
- navigationMenus={ navigationMenus }
757
728
  hasSelection={ isSelected || isInnerBlockSelected }
758
729
  />
759
730
  </ResponsiveWrapper>
@@ -2,7 +2,7 @@
2
2
  * WordPress dependencies
3
3
  */
4
4
  import {
5
- experiments as blockEditorExperiments,
5
+ privateApis as blockEditorPrivateApis,
6
6
  InspectorControls,
7
7
  store as blockEditorStore,
8
8
  } from '@wordpress/block-editor';
@@ -19,8 +19,7 @@ import { __, sprintf } from '@wordpress/i18n';
19
19
  * Internal dependencies
20
20
  */
21
21
  import NavigationMenuSelector from './navigation-menu-selector';
22
- import { LeafMoreMenu } from '../leaf-more-menu';
23
- import { unlock } from '../../experiments';
22
+ import { unlock } from '../../private-apis';
24
23
  import DeletedNavigationWarning from './deleted-navigation-warning';
25
24
  import useNavigationMenu from '../use-navigation-menu';
26
25
 
@@ -34,7 +33,7 @@ const MainContent = ( {
34
33
  isNavigationMenuMissing,
35
34
  onCreateNew,
36
35
  } ) => {
37
- const { OffCanvasEditor } = unlock( blockEditorExperiments );
36
+ const { OffCanvasEditor, LeafMoreMenu } = unlock( blockEditorPrivateApis );
38
37
  // Provide a hierarchy of clientIds for the given Navigation block (clientId).
39
38
  // This is required else the list view will display the entire block tree.
40
39
  const clientIdsTree = useSelect(
@@ -7,7 +7,6 @@ import {
7
7
  MenuItemsChoice,
8
8
  DropdownMenu,
9
9
  } from '@wordpress/components';
10
- import { useEntityProp } from '@wordpress/core-data';
11
10
  import { moreVertical } from '@wordpress/icons';
12
11
  import { __, sprintf } from '@wordpress/i18n';
13
12
  import { decodeEntities } from '@wordpress/html-entities';
@@ -41,22 +40,15 @@ function NavigationMenuSelector( {
41
40
  const {
42
41
  navigationMenus,
43
42
  hasResolvedNavigationMenus,
44
- isNavigationMenuResolved,
45
43
  canUserCreateNavigationMenu,
46
44
  canSwitchNavigationMenu,
47
45
  } = useNavigationMenu();
48
46
 
49
- const [ currentTitle ] = useEntityProp(
50
- 'postType',
51
- 'wp_navigation',
52
- 'title'
53
- );
54
-
55
47
  const menuChoices = useMemo( () => {
56
48
  return (
57
49
  navigationMenus?.map( ( { id, title }, index ) => {
58
50
  const label =
59
- decodeEntities( title.rendered ) ||
51
+ decodeEntities( title?.rendered ) ||
60
52
  /* translators: %s is the index of the menu in the list of menus. */
61
53
  sprintf( __( '(no title %s)' ), index + 1 );
62
54
 
@@ -73,14 +65,7 @@ function NavigationMenuSelector( {
73
65
  };
74
66
  } ) || []
75
67
  );
76
- }, [
77
- currentTitle,
78
- currentMenuId,
79
- navigationMenus,
80
- createNavigationMenuIsSuccess,
81
- isNavigationMenuResolved,
82
- hasResolvedNavigationMenus,
83
- ] );
68
+ }, [ currentMenuId, navigationMenus, actionLabel ] );
84
69
 
85
70
  const hasNavigationMenus = !! navigationMenus?.length;
86
71
  const hasClassicMenus = !! classicMenus?.length;
@@ -93,10 +78,10 @@ function NavigationMenuSelector( {
93
78
  hasResolvedNavigationMenus && currentMenuId === null;
94
79
 
95
80
  useEffect( () => {
96
- if ( ! hasResolvedNavigationMenus ) {
81
+ if ( ! hasResolvedNavigationMenus && ! canUserCreateNavigationMenu ) {
97
82
  setSelectorLabel( __( 'Loading …' ) );
98
83
  } else if ( noMenuSelected || noBlockMenus || menuUnavailable ) {
99
- setSelectorLabel( __( 'Choose a Navigation menu' ) );
84
+ setSelectorLabel( __( 'Choose or create a Navigation menu' ) );
100
85
  }
101
86
 
102
87
  if (
@@ -105,13 +90,7 @@ function NavigationMenuSelector( {
105
90
  ) {
106
91
  setIsCreatingMenu( false );
107
92
  }
108
- }, [
109
- currentMenuId,
110
- hasNavigationMenus,
111
- hasResolvedNavigationMenus,
112
- createNavigationMenuIsSuccess,
113
- isNavigationMenuResolved,
114
- ] );
93
+ }, [ hasResolvedNavigationMenus, createNavigationMenuIsSuccess ] );
115
94
 
116
95
  const NavigationMenuSelectorDropdown = (
117
96
  <DropdownMenu
@@ -126,9 +105,13 @@ function NavigationMenuSelector( {
126
105
  <MenuItemsChoice
127
106
  value={ currentMenuId }
128
107
  onSelect={ ( menuId ) => {
108
+ setSelectorLabel( __( 'Loading …' ) );
109
+ setIsCreatingMenu( true );
129
110
  onSelectNavigationMenu( menuId );
111
+ onClose();
130
112
  } }
131
113
  choices={ menuChoices }
114
+ disabled={ isCreatingMenu }
132
115
  />
133
116
  </MenuGroup>
134
117
  ) }
@@ -142,6 +125,7 @@ function NavigationMenuSelector( {
142
125
  setSelectorLabel(
143
126
  __( 'Loading …' )
144
127
  );
128
+ setIsCreatingMenu( true );
145
129
  onSelectClassicMenu( menu );
146
130
  onClose();
147
131
  } }
@@ -150,6 +134,7 @@ function NavigationMenuSelector( {
150
134
  createActionLabel,
151
135
  label
152
136
  ) }
137
+ disabled={ isCreatingMenu }
153
138
  >
154
139
  { label }
155
140
  </MenuItem>
@@ -161,6 +146,7 @@ function NavigationMenuSelector( {
161
146
  { canUserCreateNavigationMenu && (
162
147
  <MenuGroup label={ __( 'Tools' ) }>
163
148
  <MenuItem
149
+ disabled={ isCreatingMenu }
164
150
  onClick={ () => {
165
151
  onClose();
166
152
  onCreateNew();