@wordpress/block-library 8.30.0 → 8.32.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 (362) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/build/block/edit.js +22 -16
  3. package/build/block/edit.js.map +1 -1
  4. package/build/button/edit.native.js +1 -1
  5. package/build/button/edit.native.js.map +1 -1
  6. package/build/code/save.js +3 -1
  7. package/build/code/save.js.map +1 -1
  8. package/build/cover/edit/index.js +2 -1
  9. package/build/cover/edit/index.js.map +1 -1
  10. package/build/details/edit.js +1 -0
  11. package/build/details/edit.js.map +1 -1
  12. package/build/file/edit.js +2 -0
  13. package/build/file/edit.js.map +1 -1
  14. package/build/heading/index.js +4 -3
  15. package/build/heading/index.js.map +1 -1
  16. package/build/image/edit.js +10 -39
  17. package/build/image/edit.js.map +1 -1
  18. package/build/image/image.js +27 -6
  19. package/build/image/image.js.map +1 -1
  20. package/build/media-text/edit.js +33 -9
  21. package/build/media-text/edit.js.map +1 -1
  22. package/build/media-text/index.js +5 -0
  23. package/build/media-text/index.js.map +1 -1
  24. package/build/media-text/media-container.js +30 -11
  25. package/build/media-text/media-container.js.map +1 -1
  26. package/build/media-text/save.js +2 -2
  27. package/build/media-text/save.js.map +1 -1
  28. package/build/navigation/edit/index.js +23 -29
  29. package/build/navigation/edit/index.js.map +1 -1
  30. package/build/navigation/edit/navigation-menu-delete-control.js +12 -20
  31. package/build/navigation/edit/navigation-menu-delete-control.js.map +1 -1
  32. package/build/navigation/edit/navigation-menu-selector.js +24 -23
  33. package/build/navigation/edit/navigation-menu-selector.js.map +1 -1
  34. package/build/navigation/edit/placeholder/index.js +4 -4
  35. package/build/navigation/edit/placeholder/index.js.map +1 -1
  36. package/build/navigation/use-navigation-menu.js +15 -12
  37. package/build/navigation/use-navigation-menu.js.map +1 -1
  38. package/build/navigation/view.js +12 -2
  39. package/build/navigation/view.js.map +1 -1
  40. package/build/navigation-link/edit.js +52 -27
  41. package/build/navigation-link/edit.js.map +1 -1
  42. package/build/navigation-submenu/edit.js +31 -9
  43. package/build/navigation-submenu/edit.js.map +1 -1
  44. package/build/pattern/edit.js +3 -1
  45. package/build/pattern/edit.js.map +1 -1
  46. package/build/post-author/edit.js +1 -0
  47. package/build/post-author/edit.js.map +1 -1
  48. package/build/post-excerpt/edit.js +1 -0
  49. package/build/post-excerpt/edit.js.map +1 -1
  50. package/build/post-featured-image/edit.js +16 -4
  51. package/build/post-featured-image/edit.js.map +1 -1
  52. package/build/post-featured-image/index.js +13 -2
  53. package/build/post-featured-image/index.js.map +1 -1
  54. package/build/post-featured-image/overlay-controls.js +82 -0
  55. package/build/post-featured-image/overlay-controls.js.map +1 -0
  56. package/build/post-featured-image/overlay.js +5 -54
  57. package/build/post-featured-image/overlay.js.map +1 -1
  58. package/build/post-navigation-link/edit.js +1 -0
  59. package/build/post-navigation-link/edit.js.map +1 -1
  60. package/build/post-terms/edit.js +2 -0
  61. package/build/post-terms/edit.js.map +1 -1
  62. package/build/quote/edit.js +18 -23
  63. package/build/quote/edit.js.map +1 -1
  64. package/build/read-more/edit.js +1 -0
  65. package/build/read-more/edit.js.map +1 -1
  66. package/build/search/edit.js +2 -0
  67. package/build/search/edit.js.map +1 -1
  68. package/build/search/edit.native.js +2 -2
  69. package/build/search/edit.native.js.map +1 -1
  70. package/build/site-tagline/edit.js +13 -4
  71. package/build/site-tagline/edit.js.map +1 -1
  72. package/build/site-tagline/index.js +4 -0
  73. package/build/site-tagline/index.js.map +1 -1
  74. package/build/social-link/edit.js +1 -1
  75. package/build/social-link/edit.js.map +1 -1
  76. package/build/social-link/icons/medium.js +1 -1
  77. package/build/social-link/icons/medium.js.map +1 -1
  78. package/build/social-link/icons/reddit.js +1 -1
  79. package/build/social-link/icons/reddit.js.map +1 -1
  80. package/build/table/deprecated.js +285 -175
  81. package/build/table/deprecated.js.map +1 -1
  82. package/build/table/index.js +1 -1
  83. package/build/template-part/edit/index.js +55 -47
  84. package/build/template-part/edit/index.js.map +1 -1
  85. package/build/template-part/edit/inner-blocks.js +106 -10
  86. package/build/template-part/edit/inner-blocks.js.map +1 -1
  87. package/build/template-part/edit/selection-modal.js +1 -9
  88. package/build/template-part/edit/selection-modal.js.map +1 -1
  89. package/build/utils/caption.js +19 -13
  90. package/build/utils/caption.js.map +1 -1
  91. package/build/utils/hooks.js +1 -0
  92. package/build/utils/hooks.js.map +1 -1
  93. package/build/video/edit.native.js +1 -1
  94. package/build/video/edit.native.js.map +1 -1
  95. package/build-module/block/edit.js +23 -17
  96. package/build-module/block/edit.js.map +1 -1
  97. package/build-module/button/edit.native.js +1 -1
  98. package/build-module/button/edit.native.js.map +1 -1
  99. package/build-module/code/save.js +3 -1
  100. package/build-module/code/save.js.map +1 -1
  101. package/build-module/cover/edit/index.js +2 -1
  102. package/build-module/cover/edit/index.js.map +1 -1
  103. package/build-module/details/edit.js +1 -0
  104. package/build-module/details/edit.js.map +1 -1
  105. package/build-module/file/edit.js +2 -0
  106. package/build-module/file/edit.js.map +1 -1
  107. package/build-module/heading/index.js +4 -3
  108. package/build-module/heading/index.js.map +1 -1
  109. package/build-module/image/edit.js +11 -40
  110. package/build-module/image/edit.js.map +1 -1
  111. package/build-module/image/image.js +27 -6
  112. package/build-module/image/image.js.map +1 -1
  113. package/build-module/media-text/edit.js +34 -10
  114. package/build-module/media-text/edit.js.map +1 -1
  115. package/build-module/media-text/index.js +5 -0
  116. package/build-module/media-text/index.js.map +1 -1
  117. package/build-module/media-text/media-container.js +31 -12
  118. package/build-module/media-text/media-container.js.map +1 -1
  119. package/build-module/media-text/save.js +2 -2
  120. package/build-module/media-text/save.js.map +1 -1
  121. package/build-module/navigation/edit/index.js +24 -30
  122. package/build-module/navigation/edit/index.js.map +1 -1
  123. package/build-module/navigation/edit/navigation-menu-delete-control.js +15 -23
  124. package/build-module/navigation/edit/navigation-menu-delete-control.js.map +1 -1
  125. package/build-module/navigation/edit/navigation-menu-selector.js +24 -23
  126. package/build-module/navigation/edit/navigation-menu-selector.js.map +1 -1
  127. package/build-module/navigation/edit/placeholder/index.js +4 -4
  128. package/build-module/navigation/edit/placeholder/index.js.map +1 -1
  129. package/build-module/navigation/use-navigation-menu.js +15 -12
  130. package/build-module/navigation/use-navigation-menu.js.map +1 -1
  131. package/build-module/navigation/view.js +12 -2
  132. package/build-module/navigation/view.js.map +1 -1
  133. package/build-module/navigation-link/edit.js +55 -30
  134. package/build-module/navigation-link/edit.js.map +1 -1
  135. package/build-module/navigation-submenu/edit.js +31 -9
  136. package/build-module/navigation-submenu/edit.js.map +1 -1
  137. package/build-module/pattern/edit.js +3 -1
  138. package/build-module/pattern/edit.js.map +1 -1
  139. package/build-module/post-author/edit.js +1 -0
  140. package/build-module/post-author/edit.js.map +1 -1
  141. package/build-module/post-excerpt/edit.js +1 -0
  142. package/build-module/post-excerpt/edit.js.map +1 -1
  143. package/build-module/post-featured-image/edit.js +17 -5
  144. package/build-module/post-featured-image/edit.js.map +1 -1
  145. package/build-module/post-featured-image/index.js +13 -2
  146. package/build-module/post-featured-image/index.js.map +1 -1
  147. package/build-module/post-featured-image/overlay-controls.js +75 -0
  148. package/build-module/post-featured-image/overlay-controls.js.map +1 -0
  149. package/build-module/post-featured-image/overlay.js +7 -56
  150. package/build-module/post-featured-image/overlay.js.map +1 -1
  151. package/build-module/post-navigation-link/edit.js +1 -0
  152. package/build-module/post-navigation-link/edit.js.map +1 -1
  153. package/build-module/post-terms/edit.js +2 -0
  154. package/build-module/post-terms/edit.js.map +1 -1
  155. package/build-module/quote/edit.js +20 -25
  156. package/build-module/quote/edit.js.map +1 -1
  157. package/build-module/read-more/edit.js +1 -0
  158. package/build-module/read-more/edit.js.map +1 -1
  159. package/build-module/search/edit.js +2 -0
  160. package/build-module/search/edit.js.map +1 -1
  161. package/build-module/search/edit.native.js +2 -2
  162. package/build-module/search/edit.native.js.map +1 -1
  163. package/build-module/site-tagline/edit.js +14 -5
  164. package/build-module/site-tagline/edit.js.map +1 -1
  165. package/build-module/site-tagline/index.js +4 -0
  166. package/build-module/site-tagline/index.js.map +1 -1
  167. package/build-module/social-link/edit.js +1 -1
  168. package/build-module/social-link/edit.js.map +1 -1
  169. package/build-module/social-link/icons/medium.js +1 -1
  170. package/build-module/social-link/icons/medium.js.map +1 -1
  171. package/build-module/social-link/icons/reddit.js +1 -1
  172. package/build-module/social-link/icons/reddit.js.map +1 -1
  173. package/build-module/table/deprecated.js +286 -176
  174. package/build-module/table/deprecated.js.map +1 -1
  175. package/build-module/table/index.js +1 -1
  176. package/build-module/template-part/edit/index.js +58 -50
  177. package/build-module/template-part/edit/index.js.map +1 -1
  178. package/build-module/template-part/edit/inner-blocks.js +108 -12
  179. package/build-module/template-part/edit/inner-blocks.js.map +1 -1
  180. package/build-module/template-part/edit/selection-modal.js +2 -10
  181. package/build-module/template-part/edit/selection-modal.js.map +1 -1
  182. package/build-module/utils/caption.js +19 -13
  183. package/build-module/utils/caption.js.map +1 -1
  184. package/build-module/utils/hooks.js +1 -0
  185. package/build-module/utils/hooks.js.map +1 -1
  186. package/build-module/video/edit.native.js +1 -1
  187. package/build-module/video/edit.native.js.map +1 -1
  188. package/build-style/audio/theme-rtl.css +1 -1
  189. package/build-style/audio/theme.css +1 -1
  190. package/build-style/cover/style-rtl.css +5 -2
  191. package/build-style/cover/style.css +5 -2
  192. package/build-style/editor-rtl.css +22 -12
  193. package/build-style/editor.css +22 -12
  194. package/build-style/embed/theme-rtl.css +1 -1
  195. package/build-style/embed/theme.css +1 -1
  196. package/build-style/file/editor-rtl.css +3 -0
  197. package/build-style/file/editor.css +3 -0
  198. package/build-style/image/editor-rtl.css +0 -3
  199. package/build-style/image/editor.css +0 -3
  200. package/build-style/image/theme-rtl.css +1 -1
  201. package/build-style/image/theme.css +1 -1
  202. package/build-style/media-text/editor-rtl.css +7 -1
  203. package/build-style/media-text/editor.css +7 -1
  204. package/build-style/pullquote/theme-rtl.css +2 -1
  205. package/build-style/pullquote/theme.css +2 -1
  206. package/build-style/quote/theme-rtl.css +6 -6
  207. package/build-style/quote/theme.css +6 -6
  208. package/build-style/search/style-rtl.css +10 -0
  209. package/build-style/search/style.css +10 -0
  210. package/build-style/social-links/editor-rtl.css +0 -4
  211. package/build-style/social-links/editor.css +0 -4
  212. package/build-style/social-links/style-rtl.css +2 -2
  213. package/build-style/social-links/style.css +2 -2
  214. package/build-style/style-rtl.css +17 -4
  215. package/build-style/style.css +17 -4
  216. package/build-style/table/theme-rtl.css +4 -3
  217. package/build-style/table/theme.css +4 -3
  218. package/build-style/template-part/editor-rtl.css +12 -4
  219. package/build-style/template-part/editor.css +12 -4
  220. package/build-style/template-part/theme-rtl.css +1 -1
  221. package/build-style/template-part/theme.css +1 -1
  222. package/build-style/theme-rtl.css +17 -15
  223. package/build-style/theme.css +17 -15
  224. package/build-style/video/theme-rtl.css +1 -1
  225. package/build-style/video/theme.css +1 -1
  226. package/package.json +34 -34
  227. package/src/archives/index.php +4 -0
  228. package/src/audio/theme.scss +1 -1
  229. package/src/avatar/index.php +6 -0
  230. package/src/block/edit.js +43 -32
  231. package/src/block/index.php +4 -0
  232. package/src/block/test/edit.native.js +67 -0
  233. package/src/button/edit.native.js +1 -1
  234. package/src/calendar/index.php +12 -0
  235. package/src/categories/index.php +6 -0
  236. package/src/code/save.js +7 -1
  237. package/src/comment-author-name/index.php +4 -0
  238. package/src/comment-content/index.php +4 -0
  239. package/src/comment-date/index.php +4 -0
  240. package/src/comment-edit-link/index.php +4 -0
  241. package/src/comment-reply-link/index.php +4 -0
  242. package/src/comment-template/index.php +4 -0
  243. package/src/comments/index.php +10 -0
  244. package/src/comments-pagination/index.php +4 -0
  245. package/src/comments-pagination-next/index.php +4 -0
  246. package/src/comments-pagination-numbers/index.php +4 -0
  247. package/src/comments-pagination-previous/index.php +4 -0
  248. package/src/comments-title/index.php +4 -0
  249. package/src/cover/edit/index.js +4 -1
  250. package/src/cover/index.php +4 -0
  251. package/src/cover/style.scss +6 -2
  252. package/src/details/edit.js +1 -0
  253. package/src/embed/theme.scss +1 -1
  254. package/src/file/edit.js +2 -0
  255. package/src/file/editor.scss +3 -0
  256. package/src/file/index.php +4 -0
  257. package/src/gallery/editor.scss +1 -1
  258. package/src/gallery/index.php +7 -1
  259. package/src/heading/index.js +4 -3
  260. package/src/heading/index.php +4 -0
  261. package/src/home-link/index.php +10 -0
  262. package/src/image/edit.js +11 -40
  263. package/src/image/editor.scss +2 -7
  264. package/src/image/image.js +25 -7
  265. package/src/image/index.php +12 -1
  266. package/src/image/theme.scss +1 -1
  267. package/src/latest-comments/index.php +4 -0
  268. package/src/latest-posts/index.php +8 -0
  269. package/src/loginout/index.php +4 -0
  270. package/src/media-text/block.json +5 -0
  271. package/src/media-text/edit.js +70 -19
  272. package/src/media-text/editor.scss +7 -1
  273. package/src/media-text/index.php +70 -0
  274. package/src/media-text/media-container.js +49 -9
  275. package/src/media-text/save.js +2 -2
  276. package/src/navigation/edit/index.js +67 -71
  277. package/src/navigation/edit/navigation-menu-delete-control.js +22 -49
  278. package/src/navigation/edit/navigation-menu-selector.js +39 -21
  279. package/src/navigation/edit/placeholder/index.js +4 -4
  280. package/src/navigation/edit/test/navigation-menu-selector.js +75 -53
  281. package/src/navigation/index.php +109 -26
  282. package/src/navigation/test/use-navigation-menu.js +21 -21
  283. package/src/navigation/use-navigation-menu.js +23 -9
  284. package/src/navigation/view.js +11 -2
  285. package/src/navigation-link/edit.js +64 -39
  286. package/src/navigation-link/index.php +14 -0
  287. package/src/navigation-submenu/edit.js +34 -10
  288. package/src/navigation-submenu/index.php +8 -0
  289. package/src/page-list/index.php +12 -0
  290. package/src/page-list-item/index.php +2 -0
  291. package/src/pattern/edit.js +4 -0
  292. package/src/pattern/index.php +2 -0
  293. package/src/post-author/edit.js +1 -0
  294. package/src/post-author/index.php +4 -0
  295. package/src/post-author-biography/index.php +4 -0
  296. package/src/post-author-name/index.php +4 -0
  297. package/src/post-comments-form/index.php +6 -0
  298. package/src/post-content/index.php +4 -0
  299. package/src/post-date/index.php +4 -0
  300. package/src/post-excerpt/edit.js +1 -0
  301. package/src/post-excerpt/index.php +4 -0
  302. package/src/post-featured-image/block.json +13 -2
  303. package/src/post-featured-image/edit.js +16 -1
  304. package/src/post-featured-image/editor.scss +1 -1
  305. package/src/post-featured-image/index.php +15 -0
  306. package/src/post-featured-image/overlay-controls.js +88 -0
  307. package/src/post-featured-image/overlay.js +17 -84
  308. package/src/post-navigation-link/edit.js +1 -0
  309. package/src/post-navigation-link/index.php +4 -0
  310. package/src/post-template/index.php +4 -0
  311. package/src/post-terms/edit.js +2 -0
  312. package/src/post-terms/index.php +6 -0
  313. package/src/post-title/index.php +2 -0
  314. package/src/pullquote/theme.scss +3 -1
  315. package/src/query/index.php +2 -0
  316. package/src/query-no-results/index.php +6 -0
  317. package/src/query-pagination/index.php +4 -0
  318. package/src/query-pagination-next/index.php +6 -0
  319. package/src/query-pagination-numbers/index.php +6 -0
  320. package/src/query-pagination-previous/index.php +4 -0
  321. package/src/query-title/index.php +4 -0
  322. package/src/quote/edit.js +27 -37
  323. package/src/quote/test/edit.native.js +4 -6
  324. package/src/quote/theme.scss +1 -2
  325. package/src/read-more/edit.js +1 -0
  326. package/src/read-more/index.php +4 -0
  327. package/src/rss/index.php +4 -0
  328. package/src/search/edit.js +2 -0
  329. package/src/search/edit.native.js +2 -2
  330. package/src/search/index.php +19 -1
  331. package/src/search/style.scss +11 -0
  332. package/src/shortcode/index.php +4 -0
  333. package/src/site-logo/editor.scss +2 -2
  334. package/src/site-logo/index.php +20 -0
  335. package/src/site-tagline/block.json +4 -0
  336. package/src/site-tagline/edit.js +16 -3
  337. package/src/site-tagline/index.php +13 -1
  338. package/src/site-title/index.php +4 -0
  339. package/src/social-link/edit.js +1 -1
  340. package/src/social-link/icons/medium.js +1 -1
  341. package/src/social-link/icons/reddit.js +1 -1
  342. package/src/social-link/index.php +22 -9
  343. package/src/social-link/socials-with-bg.scss +1 -1
  344. package/src/social-link/socials-without-bg.scss +1 -1
  345. package/src/social-links/editor.scss +1 -9
  346. package/src/table/block.json +1 -1
  347. package/src/table/deprecated.js +308 -175
  348. package/src/table/theme.scss +4 -2
  349. package/src/tag-cloud/index.php +4 -0
  350. package/src/template-part/edit/index.js +87 -79
  351. package/src/template-part/edit/inner-blocks.js +126 -13
  352. package/src/template-part/edit/selection-modal.js +1 -22
  353. package/src/template-part/editor.scss +11 -3
  354. package/src/template-part/index.php +12 -0
  355. package/src/template-part/theme.scss +1 -1
  356. package/src/term-description/index.php +4 -0
  357. package/src/utils/caption.js +19 -16
  358. package/src/utils/hooks.js +1 -0
  359. package/src/video/edit.native.js +2 -0
  360. package/src/video/editor.scss +2 -2
  361. package/src/video/theme.scss +1 -1
  362. package/tsconfig.json +1 -0
@@ -117,16 +117,16 @@ describe( 'useNavigationMenus', () => {
117
117
  navigationMenus: null,
118
118
  navigationMenu: undefined,
119
119
  canSwitchNavigationMenu: false,
120
- canUserCreateNavigationMenu: false,
120
+ canUserCreateNavigationMenus: false,
121
121
  canUserDeleteNavigationMenu: undefined,
122
122
  canUserUpdateNavigationMenu: undefined,
123
- hasResolvedCanUserCreateNavigationMenu: false,
123
+ hasResolvedCanUserCreateNavigationMenus: false,
124
124
  hasResolvedCanUserDeleteNavigationMenu: undefined,
125
125
  hasResolvedCanUserUpdateNavigationMenu: undefined,
126
126
  hasResolvedNavigationMenus: false,
127
127
  isNavigationMenuMissing: true,
128
128
  isNavigationMenuResolved: false,
129
- isResolvingCanUserCreateNavigationMenu: false,
129
+ isResolvingCanUserCreateNavigationMenus: false,
130
130
  isResolvingNavigationMenus: false,
131
131
  } );
132
132
  } );
@@ -139,16 +139,16 @@ describe( 'useNavigationMenus', () => {
139
139
  navigationMenus,
140
140
  navigationMenu: undefined,
141
141
  canSwitchNavigationMenu: true,
142
- canUserCreateNavigationMenu: true,
142
+ canUserCreateNavigationMenus: true,
143
143
  canUserDeleteNavigationMenu: undefined,
144
144
  canUserUpdateNavigationMenu: undefined,
145
- hasResolvedCanUserCreateNavigationMenu: true,
145
+ hasResolvedCanUserCreateNavigationMenus: true,
146
146
  hasResolvedCanUserDeleteNavigationMenu: undefined,
147
147
  hasResolvedCanUserUpdateNavigationMenu: undefined,
148
148
  hasResolvedNavigationMenus: true,
149
149
  isNavigationMenuMissing: true,
150
150
  isNavigationMenuResolved: false,
151
- isResolvingCanUserCreateNavigationMenu: false,
151
+ isResolvingCanUserCreateNavigationMenus: false,
152
152
  isResolvingNavigationMenus: false,
153
153
  } );
154
154
  } );
@@ -159,16 +159,16 @@ describe( 'useNavigationMenus', () => {
159
159
  navigationMenu: navigationMenu1,
160
160
  navigationMenus,
161
161
  canSwitchNavigationMenu: true,
162
- canUserCreateNavigationMenu: false,
162
+ canUserCreateNavigationMenus: false,
163
163
  canUserDeleteNavigationMenu: false,
164
164
  canUserUpdateNavigationMenu: false,
165
- hasResolvedCanUserCreateNavigationMenu: false,
165
+ hasResolvedCanUserCreateNavigationMenus: false,
166
166
  hasResolvedCanUserDeleteNavigationMenu: false,
167
167
  hasResolvedCanUserUpdateNavigationMenu: false,
168
168
  hasResolvedNavigationMenus: true,
169
169
  isNavigationMenuMissing: false,
170
170
  isNavigationMenuResolved: false,
171
- isResolvingCanUserCreateNavigationMenu: false,
171
+ isResolvingCanUserCreateNavigationMenus: false,
172
172
  isResolvingNavigationMenus: false,
173
173
  } );
174
174
  } );
@@ -181,16 +181,16 @@ describe( 'useNavigationMenus', () => {
181
181
  navigationMenu: navigationMenuDraft,
182
182
  navigationMenus: testMenus,
183
183
  canSwitchNavigationMenu: true,
184
- canUserCreateNavigationMenu: false,
184
+ canUserCreateNavigationMenus: false,
185
185
  canUserDeleteNavigationMenu: false,
186
186
  canUserUpdateNavigationMenu: false,
187
- hasResolvedCanUserCreateNavigationMenu: false,
187
+ hasResolvedCanUserCreateNavigationMenus: false,
188
188
  hasResolvedCanUserDeleteNavigationMenu: false,
189
189
  hasResolvedCanUserUpdateNavigationMenu: false,
190
190
  hasResolvedNavigationMenus: true,
191
191
  isNavigationMenuMissing: false,
192
192
  isNavigationMenuResolved: false,
193
- isResolvingCanUserCreateNavigationMenu: false,
193
+ isResolvingCanUserCreateNavigationMenus: false,
194
194
  isResolvingNavigationMenus: false,
195
195
  } );
196
196
  } );
@@ -205,16 +205,16 @@ describe( 'useNavigationMenus', () => {
205
205
  navigationMenu: navigationMenu1,
206
206
  navigationMenus,
207
207
  canSwitchNavigationMenu: true,
208
- canUserCreateNavigationMenu: true,
208
+ canUserCreateNavigationMenus: true,
209
209
  canUserDeleteNavigationMenu: false,
210
210
  canUserUpdateNavigationMenu: true,
211
- hasResolvedCanUserCreateNavigationMenu: true,
211
+ hasResolvedCanUserCreateNavigationMenus: true,
212
212
  hasResolvedCanUserDeleteNavigationMenu: true,
213
213
  hasResolvedCanUserUpdateNavigationMenu: true,
214
214
  hasResolvedNavigationMenus: true,
215
215
  isNavigationMenuMissing: false,
216
216
  isNavigationMenuResolved: false,
217
- isResolvingCanUserCreateNavigationMenu: false,
217
+ isResolvingCanUserCreateNavigationMenus: false,
218
218
  isResolvingNavigationMenus: false,
219
219
  } );
220
220
  } );
@@ -229,16 +229,16 @@ describe( 'useNavigationMenus', () => {
229
229
  navigationMenu: navigationMenu1,
230
230
  navigationMenus,
231
231
  canSwitchNavigationMenu: true,
232
- canUserCreateNavigationMenu: false,
232
+ canUserCreateNavigationMenus: false,
233
233
  canUserDeleteNavigationMenu: true,
234
234
  canUserUpdateNavigationMenu: false,
235
- hasResolvedCanUserCreateNavigationMenu: true,
235
+ hasResolvedCanUserCreateNavigationMenus: true,
236
236
  hasResolvedCanUserDeleteNavigationMenu: true,
237
237
  hasResolvedCanUserUpdateNavigationMenu: true,
238
238
  hasResolvedNavigationMenus: true,
239
239
  isNavigationMenuMissing: false,
240
240
  isNavigationMenuResolved: false,
241
- isResolvingCanUserCreateNavigationMenu: false,
241
+ isResolvingCanUserCreateNavigationMenus: false,
242
242
  isResolvingNavigationMenus: false,
243
243
  } );
244
244
  } );
@@ -254,16 +254,16 @@ describe( 'useNavigationMenus', () => {
254
254
  navigationMenu: requestedMenu,
255
255
  navigationMenus,
256
256
  canSwitchNavigationMenu: true,
257
- canUserCreateNavigationMenu: false,
257
+ canUserCreateNavigationMenus: false,
258
258
  canUserDeleteNavigationMenu: false,
259
259
  canUserUpdateNavigationMenu: false,
260
- hasResolvedCanUserCreateNavigationMenu: false,
260
+ hasResolvedCanUserCreateNavigationMenus: false,
261
261
  hasResolvedCanUserDeleteNavigationMenu: false,
262
262
  hasResolvedCanUserUpdateNavigationMenu: false,
263
263
  hasResolvedNavigationMenus: true,
264
264
  isNavigationMenuMissing: false,
265
265
  isNavigationMenuResolved: false,
266
- isResolvingCanUserCreateNavigationMenu: false,
266
+ isResolvingCanUserCreateNavigationMenus: false,
267
267
  isResolvingNavigationMenus: false,
268
268
  } );
269
269
  } );
@@ -27,8 +27,18 @@ export default function useNavigationMenu( ref ) {
27
27
  [ ref ]
28
28
  );
29
29
 
30
- const { canCreate, canUpdate, canDelete, isResolving, hasResolved } =
31
- permissions;
30
+ const {
31
+ // Can the user create navigation menus?
32
+ canCreate: canCreateNavigationMenus,
33
+
34
+ // Can the user update the specific navigation menu with the given post ID?
35
+ canUpdate: canUpdateNavigationMenu,
36
+
37
+ // Can the user delete the specific navigation menu with the given post ID?
38
+ canDelete: canDeleteNavigationMenu,
39
+ isResolving: isResolvingPermissions,
40
+ hasResolved: hasResolvedPermissions,
41
+ } = permissions;
32
42
 
33
43
  const {
34
44
  records: navigationMenus,
@@ -52,13 +62,17 @@ export default function useNavigationMenu( ref ) {
52
62
  isResolvingNavigationMenus,
53
63
  hasResolvedNavigationMenus,
54
64
  canSwitchNavigationMenu,
55
- canUserCreateNavigationMenu: canCreate,
56
- isResolvingCanUserCreateNavigationMenu: isResolving,
57
- hasResolvedCanUserCreateNavigationMenu: hasResolved,
58
- canUserUpdateNavigationMenu: canUpdate,
59
- hasResolvedCanUserUpdateNavigationMenu: ref ? hasResolved : undefined,
60
- canUserDeleteNavigationMenu: canDelete,
61
- hasResolvedCanUserDeleteNavigationMenu: ref ? hasResolved : undefined,
65
+ canUserCreateNavigationMenus: canCreateNavigationMenus,
66
+ isResolvingCanUserCreateNavigationMenus: isResolvingPermissions,
67
+ hasResolvedCanUserCreateNavigationMenus: hasResolvedPermissions,
68
+ canUserUpdateNavigationMenu: canUpdateNavigationMenu,
69
+ hasResolvedCanUserUpdateNavigationMenu: ref
70
+ ? hasResolvedPermissions
71
+ : undefined,
72
+ canUserDeleteNavigationMenu: canDeleteNavigationMenu,
73
+ hasResolvedCanUserDeleteNavigationMenu: ref
74
+ ? hasResolvedPermissions
75
+ : undefined,
62
76
  };
63
77
  }
64
78
 
@@ -62,11 +62,20 @@ const { state, actions } = store(
62
62
  // Only open on hover if the overlay is closed.
63
63
  Object.values( overlayOpenedBy || {} ).filter( Boolean )
64
64
  .length === 0
65
- )
65
+ ) {
66
66
  actions.openMenu( 'hover' );
67
+ }
67
68
  },
68
69
  closeMenuOnHover() {
69
- actions.closeMenu( 'hover' );
70
+ const { type, overlayOpenedBy } = getContext();
71
+ if (
72
+ type === 'submenu' &&
73
+ // Only close on hover if the overlay is closed.
74
+ Object.values( overlayOpenedBy || {} ).filter( Boolean )
75
+ .length === 0
76
+ ) {
77
+ actions.closeMenu( 'hover' );
78
+ }
70
79
  },
71
80
  openMenuOnClick() {
72
81
  const ctx = getContext();
@@ -16,7 +16,7 @@ import {
16
16
  Tooltip,
17
17
  ToolbarGroup,
18
18
  } from '@wordpress/components';
19
- import { displayShortcut, isKeyboardEvent, ENTER } from '@wordpress/keycodes';
19
+ import { displayShortcut, isKeyboardEvent } from '@wordpress/keycodes';
20
20
  import { __ } from '@wordpress/i18n';
21
21
  import {
22
22
  BlockControls,
@@ -29,14 +29,11 @@ import {
29
29
  } from '@wordpress/block-editor';
30
30
  import { isURL, prependHTTP, safeDecodeURI } from '@wordpress/url';
31
31
  import { useState, useEffect, useRef } from '@wordpress/element';
32
- import {
33
- placeCaretAtHorizontalEdge,
34
- __unstableStripHTML as stripHTML,
35
- } from '@wordpress/dom';
32
+ import { __unstableStripHTML as stripHTML } from '@wordpress/dom';
36
33
  import { decodeEntities } from '@wordpress/html-entities';
37
34
  import { link as linkIcon, addSubmenu } from '@wordpress/icons';
38
35
  import { store as coreStore } from '@wordpress/core-data';
39
- import { useMergeRefs } from '@wordpress/compose';
36
+ import { useMergeRefs, usePrevious } from '@wordpress/compose';
40
37
 
41
38
  /**
42
39
  * Internal dependencies
@@ -93,7 +90,7 @@ const useIsDraggingWithin = ( elementRef ) => {
93
90
  ownerDocument.removeEventListener( 'dragend', handleDragEnd );
94
91
  ownerDocument.removeEventListener( 'dragenter', handleDragEnter );
95
92
  };
96
- }, [] );
93
+ }, [ elementRef ] );
97
94
 
98
95
  return isDraggingWithin;
99
96
  };
@@ -171,9 +168,14 @@ export default function NavigationLinkEdit( {
171
168
  const [ isInvalid, isDraft ] = useIsInvalidLink( kind, type, id );
172
169
  const { maxNestingLevel } = context;
173
170
 
174
- const { replaceBlock, __unstableMarkNextChangeAsNotPersistent } =
175
- useDispatch( blockEditorStore );
171
+ const {
172
+ replaceBlock,
173
+ __unstableMarkNextChangeAsNotPersistent,
174
+ selectPreviousBlock,
175
+ } = useDispatch( blockEditorStore );
176
176
  const [ isLinkOpen, setIsLinkOpen ] = useState( false );
177
+ // Store what element opened the popover, so we know where to return focus to (toolbar button vs navigation link text)
178
+ const [ openedBy, setOpenedBy ] = useState( null );
177
179
  // Use internal state instead of a ref to make sure that the component
178
180
  // re-renders when the popover's anchor updates.
179
181
  const [ popoverAnchor, setPopoverAnchor ] = useState( null );
@@ -181,6 +183,7 @@ export default function NavigationLinkEdit( {
181
183
  const isDraggingWithin = useIsDraggingWithin( listItemRef );
182
184
  const itemLabelPlaceholder = __( 'Add label…' );
183
185
  const ref = useRef();
186
+ const prevUrl = usePrevious( url );
184
187
 
185
188
  // Change the label using inspector causes rich text to change focus on firefox.
186
189
  // This is a workaround to keep the focus on the label field when label filed is focused we don't render the rich text.
@@ -220,13 +223,13 @@ export default function NavigationLinkEdit( {
220
223
  hasChildren: !! getBlockCount( clientId ),
221
224
  };
222
225
  },
223
- [ clientId ]
226
+ [ clientId, maxNestingLevel ]
224
227
  );
225
228
 
226
229
  /**
227
230
  * Transform to submenu block.
228
231
  */
229
- function transformToSubmenu() {
232
+ const transformToSubmenu = () => {
230
233
  const newSubmenu = createBlock(
231
234
  'core/navigation-submenu',
232
235
  attributes,
@@ -235,7 +238,7 @@ export default function NavigationLinkEdit( {
235
238
  : [ createBlock( 'core/navigation-link' ) ]
236
239
  );
237
240
  replaceBlock( clientId, newSubmenu );
238
- }
241
+ };
239
242
 
240
243
  useEffect( () => {
241
244
  // Show the LinkControl on mount if the URL is empty
@@ -269,20 +272,18 @@ export default function NavigationLinkEdit( {
269
272
 
270
273
  // If the LinkControl popover is open and the URL has changed, close the LinkControl and focus the label text.
271
274
  useEffect( () => {
272
- if ( isLinkOpen && url ) {
273
- // Does this look like a URL and have something TLD-ish?
274
- if (
275
- isURL( prependHTTP( label ) ) &&
276
- /^.+\.[a-z]+/.test( label )
277
- ) {
278
- // Focus and select the label text.
279
- selectLabelText();
280
- } else {
281
- // Focus it (but do not select).
282
- placeCaretAtHorizontalEdge( ref.current, true );
283
- }
275
+ // We only want to do this when the URL has gone from nothing to a new URL AND the label looks like a URL
276
+ if (
277
+ ! prevUrl &&
278
+ url &&
279
+ isLinkOpen &&
280
+ isURL( prependHTTP( label ) ) &&
281
+ /^.+\.[a-z]+/.test( label )
282
+ ) {
283
+ // Focus and select the label text.
284
+ selectLabelText();
284
285
  }
285
- }, [ url ] );
286
+ }, [ prevUrl, url, isLinkOpen, label ] );
286
287
 
287
288
  /**
288
289
  * Focus the Link label text and select it.
@@ -329,11 +330,15 @@ export default function NavigationLinkEdit( {
329
330
  } = getColors( context, ! isTopLevelLink );
330
331
 
331
332
  function onKeyDown( event ) {
332
- if (
333
- isKeyboardEvent.primary( event, 'k' ) ||
334
- ( ( ! url || isDraft || isInvalid ) && event.keyCode === ENTER )
335
- ) {
333
+ if ( isKeyboardEvent.primary( event, 'k' ) ) {
334
+ // Required to prevent the command center from opening,
335
+ // as it shares the CMD+K shortcut.
336
+ // See https://github.com/WordPress/gutenberg/pull/59845.
337
+ event.preventDefault();
338
+ // If this link is a child of a parent submenu item, the parent submenu item event will also open, closing this popover
339
+ event.stopPropagation();
336
340
  setIsLinkOpen( true );
341
+ setOpenedBy( ref.current );
337
342
  }
338
343
  }
339
344
 
@@ -370,7 +375,10 @@ export default function NavigationLinkEdit( {
370
375
  );
371
376
 
372
377
  if ( ! url || isInvalid || isDraft ) {
373
- blockProps.onClick = () => setIsLinkOpen( true );
378
+ blockProps.onClick = () => {
379
+ setIsLinkOpen( true );
380
+ setOpenedBy( ref.current );
381
+ };
374
382
  }
375
383
 
376
384
  const classes = classnames( 'wp-block-navigation-item__content', {
@@ -396,7 +404,10 @@ export default function NavigationLinkEdit( {
396
404
  icon={ linkIcon }
397
405
  title={ __( 'Link' ) }
398
406
  shortcut={ displayShortcut.primary( 'k' ) }
399
- onClick={ () => setIsLinkOpen( true ) }
407
+ onClick={ ( event ) => {
408
+ setIsLinkOpen( true );
409
+ setOpenedBy( event.currentTarget );
410
+ } }
400
411
  />
401
412
  { ! isAtMaxNesting && (
402
413
  <ToolbarButton
@@ -413,17 +424,19 @@ export default function NavigationLinkEdit( {
413
424
  <PanelBody title={ __( 'Settings' ) }>
414
425
  <TextControl
415
426
  __nextHasNoMarginBottom
427
+ __next40pxDefaultSize
416
428
  value={ label ? stripHTML( label ) : '' }
417
429
  onChange={ ( labelValue ) => {
418
430
  setAttributes( { label: labelValue } );
419
431
  } }
420
- label={ __( 'Label' ) }
432
+ label={ __( 'Text' ) }
421
433
  autoComplete="off"
422
434
  onFocus={ () => setIsLabelFieldFocused( true ) }
423
435
  onBlur={ () => setIsLabelFieldFocused( false ) }
424
436
  />
425
437
  <TextControl
426
438
  __nextHasNoMarginBottom
439
+ __next40pxDefaultSize
427
440
  value={ url ? safeDecodeURI( url ) : '' }
428
441
  onChange={ ( urlValue ) => {
429
442
  updateAttributes(
@@ -432,7 +445,7 @@ export default function NavigationLinkEdit( {
432
445
  attributes
433
446
  );
434
447
  } }
435
- label={ __( 'URL' ) }
448
+ label={ __( 'Link' ) }
436
449
  autoComplete="off"
437
450
  />
438
451
  <TextareaControl
@@ -448,6 +461,7 @@ export default function NavigationLinkEdit( {
448
461
  />
449
462
  <TextControl
450
463
  __nextHasNoMarginBottom
464
+ __next40pxDefaultSize
451
465
  value={ title || '' }
452
466
  onChange={ ( titleValue ) => {
453
467
  setAttributes( { title: titleValue } );
@@ -460,6 +474,7 @@ export default function NavigationLinkEdit( {
460
474
  />
461
475
  <TextControl
462
476
  __nextHasNoMarginBottom
477
+ __next40pxDefaultSize
463
478
  value={ rel || '' }
464
479
  onChange={ ( relValue ) => {
465
480
  setAttributes( { rel: relValue } );
@@ -518,11 +533,6 @@ export default function NavigationLinkEdit( {
518
533
  'core/image',
519
534
  'core/strikethrough',
520
535
  ] }
521
- onClick={ () => {
522
- if ( ! url ) {
523
- setIsLinkOpen( true );
524
- }
525
- } }
526
536
  />
527
537
  { description && (
528
538
  <span className="wp-block-navigation-item__description">
@@ -567,8 +577,23 @@ export default function NavigationLinkEdit( {
567
577
  // If there is no link then remove the auto-inserted block.
568
578
  // This avoids empty blocks which can provided a poor UX.
569
579
  if ( ! url ) {
570
- // Need to handle refocusing the Nav block or the inserter?
580
+ // Select the previous block to keep focus nearby
581
+ selectPreviousBlock( clientId, true );
582
+ // Remove the link.
571
583
  onReplace( [] );
584
+ return;
585
+ }
586
+
587
+ setIsLinkOpen( false );
588
+ if ( openedBy ) {
589
+ openedBy.focus();
590
+ setOpenedBy( null );
591
+ } else if ( ref.current ) {
592
+ // select the ref when adding a new link
593
+ ref.current.focus();
594
+ } else {
595
+ // Fallback
596
+ selectPreviousBlock( clientId, true );
572
597
  }
573
598
  } }
574
599
  anchor={ popoverAnchor }
@@ -9,6 +9,8 @@
9
9
  * Build an array with CSS classes and inline styles defining the colors
10
10
  * which will be applied to the navigation markup in the front-end.
11
11
  *
12
+ * @since 5.9.0
13
+ *
12
14
  * @param array $context Navigation block context.
13
15
  * @param array $attributes Block attributes.
14
16
  * @param bool $is_sub_menu Whether the link is part of a sub-menu.
@@ -79,6 +81,8 @@ function block_core_navigation_link_build_css_colors( $context, $attributes, $is
79
81
  * Build an array with CSS classes and inline styles defining the font sizes
80
82
  * which will be applied to the navigation markup in the front-end.
81
83
  *
84
+ * @since 5.9.0
85
+ *
82
86
  * @param array $context Navigation block context.
83
87
  * @return array Font size CSS classes and inline styles.
84
88
  */
@@ -113,6 +117,8 @@ function block_core_navigation_link_build_css_font_sizes( $context ) {
113
117
  /**
114
118
  * Returns the top-level submenu SVG chevron icon.
115
119
  *
120
+ * @since 5.9.0
121
+ *
116
122
  * @return string
117
123
  */
118
124
  function block_core_navigation_link_render_submenu_icon() {
@@ -122,6 +128,8 @@ function block_core_navigation_link_render_submenu_icon() {
122
128
  /**
123
129
  * Decodes a url if it's encoded, returning the same url if not.
124
130
  *
131
+ * @since 6.2.0
132
+ *
125
133
  * @param string $url The url to decode.
126
134
  *
127
135
  * @return string $url Returns the decoded url.
@@ -153,6 +161,8 @@ function block_core_navigation_link_maybe_urldecode( $url ) {
153
161
  /**
154
162
  * Renders the `core/navigation-link` block.
155
163
  *
164
+ * @since 5.9.0
165
+ *
156
166
  * @param array $attributes The block attributes.
157
167
  * @param string $content The saved content.
158
168
  * @param WP_Block $block The parsed block.
@@ -269,6 +279,8 @@ function render_block_core_navigation_link( $attributes, $content, $block ) {
269
279
  /**
270
280
  * Returns a navigation link variation
271
281
  *
282
+ * @since 5.9.0
283
+ *
272
284
  * @param WP_Taxonomy|WP_Post_Type $entity post type or taxonomy entity.
273
285
  * @param string $kind string of value 'taxonomy' or 'post-type'.
274
286
  *
@@ -391,6 +403,8 @@ function block_core_navigation_link_build_variations() {
391
403
  /**
392
404
  * Registers the navigation link block.
393
405
  *
406
+ * @since 5.9.0
407
+ *
394
408
  * @uses render_block_core_navigation_link()
395
409
  * @throws WP_Error An WP_Error exception parsing the block definition.
396
410
  */
@@ -28,7 +28,6 @@ import {
28
28
  } from '@wordpress/block-editor';
29
29
  import { isURL, prependHTTP } from '@wordpress/url';
30
30
  import { useState, useEffect, useRef } from '@wordpress/element';
31
- import { placeCaretAtHorizontalEdge } from '@wordpress/dom';
32
31
  import { link as linkIcon, removeSubmenu } from '@wordpress/icons';
33
32
  import { useResourcePermissions } from '@wordpress/core-data';
34
33
  import { speak } from '@wordpress/a11y';
@@ -139,9 +138,14 @@ export default function NavigationSubmenuEdit( {
139
138
 
140
139
  const { showSubmenuIcon, maxNestingLevel, openSubmenusOnClick } = context;
141
140
 
142
- const { __unstableMarkNextChangeAsNotPersistent, replaceBlock } =
143
- useDispatch( blockEditorStore );
141
+ const {
142
+ __unstableMarkNextChangeAsNotPersistent,
143
+ replaceBlock,
144
+ selectBlock,
145
+ } = useDispatch( blockEditorStore );
144
146
  const [ isLinkOpen, setIsLinkOpen ] = useState( false );
147
+ // Store what element opened the popover, so we know where to return focus to (toolbar button vs navigation link text)
148
+ const [ openedBy, setOpenedBy ] = useState( null );
145
149
  // Use internal state instead of a ref to make sure that the component
146
150
  // re-renders when the popover's anchor updates.
147
151
  const [ popoverAnchor, setPopoverAnchor ] = useState( null );
@@ -241,9 +245,6 @@ export default function NavigationSubmenuEdit( {
241
245
  ) {
242
246
  // Focus and select the label text.
243
247
  selectLabelText();
244
- } else {
245
- // Focus it (but do not select).
246
- placeCaretAtHorizontalEdge( ref.current, true );
247
248
  }
248
249
  }
249
250
  }, [ url ] );
@@ -279,7 +280,14 @@ export default function NavigationSubmenuEdit( {
279
280
 
280
281
  function onKeyDown( event ) {
281
282
  if ( isKeyboardEvent.primary( event, 'k' ) ) {
283
+ // Required to prevent the command center from opening,
284
+ // as it shares the CMD+K shortcut.
285
+ // See https://github.com/WordPress/gutenberg/pull/59845.
286
+ event.preventDefault();
287
+ // If we don't stop propogation, this event bubbles up to the parent submenu item
288
+ event.stopPropagation();
282
289
  setIsLinkOpen( true );
290
+ setOpenedBy( ref.current );
283
291
  }
284
292
  }
285
293
 
@@ -366,7 +374,10 @@ export default function NavigationSubmenuEdit( {
366
374
  icon={ linkIcon }
367
375
  title={ __( 'Link' ) }
368
376
  shortcut={ displayShortcut.primary( 'k' ) }
369
- onClick={ () => setIsLinkOpen( true ) }
377
+ onClick={ ( event ) => {
378
+ setIsLinkOpen( true );
379
+ setOpenedBy( event.currentTarget );
380
+ } }
370
381
  />
371
382
  ) }
372
383
 
@@ -385,20 +396,22 @@ export default function NavigationSubmenuEdit( {
385
396
  <PanelBody title={ __( 'Settings' ) }>
386
397
  <TextControl
387
398
  __nextHasNoMarginBottom
399
+ __next40pxDefaultSize
388
400
  value={ label || '' }
389
401
  onChange={ ( labelValue ) => {
390
402
  setAttributes( { label: labelValue } );
391
403
  } }
392
- label={ __( 'Label' ) }
404
+ label={ __( 'Text' ) }
393
405
  autoComplete="off"
394
406
  />
395
407
  <TextControl
396
408
  __nextHasNoMarginBottom
409
+ __next40pxDefaultSize
397
410
  value={ url || '' }
398
411
  onChange={ ( urlValue ) => {
399
412
  setAttributes( { url: urlValue } );
400
413
  } }
401
- label={ __( 'URL' ) }
414
+ label={ __( 'Link' ) }
402
415
  autoComplete="off"
403
416
  />
404
417
  <TextareaControl
@@ -416,6 +429,7 @@ export default function NavigationSubmenuEdit( {
416
429
  />
417
430
  <TextControl
418
431
  __nextHasNoMarginBottom
432
+ __next40pxDefaultSize
419
433
  value={ title || '' }
420
434
  onChange={ ( titleValue ) => {
421
435
  setAttributes( { title: titleValue } );
@@ -428,6 +442,7 @@ export default function NavigationSubmenuEdit( {
428
442
  />
429
443
  <TextControl
430
444
  __nextHasNoMarginBottom
445
+ __next40pxDefaultSize
431
446
  value={ rel || '' }
432
447
  onChange={ ( relValue ) => {
433
448
  setAttributes( { rel: relValue } );
@@ -467,6 +482,7 @@ export default function NavigationSubmenuEdit( {
467
482
  onClick={ () => {
468
483
  if ( ! openSubmenusOnClick && ! url ) {
469
484
  setIsLinkOpen( true );
485
+ setOpenedBy( ref.current );
470
486
  }
471
487
  } }
472
488
  />
@@ -475,7 +491,15 @@ export default function NavigationSubmenuEdit( {
475
491
  <LinkUI
476
492
  clientId={ clientId }
477
493
  link={ attributes }
478
- onClose={ () => setIsLinkOpen( false ) }
494
+ onClose={ () => {
495
+ setIsLinkOpen( false );
496
+ if ( openedBy ) {
497
+ openedBy.focus();
498
+ setOpenedBy( null );
499
+ } else {
500
+ selectBlock( clientId );
501
+ }
502
+ } }
479
503
  anchor={ popoverAnchor }
480
504
  hasCreateSuggestion={ userCanCreate }
481
505
  onRemove={ () => {
@@ -9,6 +9,8 @@
9
9
  * Build an array with CSS classes and inline styles defining the font sizes
10
10
  * which will be applied to the navigation markup in the front-end.
11
11
  *
12
+ * @since 5.9.0
13
+ *
12
14
  * @param array $context Navigation block context.
13
15
  * @return array Font size CSS classes and inline styles.
14
16
  */
@@ -43,6 +45,8 @@ function block_core_navigation_submenu_build_css_font_sizes( $context ) {
43
45
  /**
44
46
  * Returns the top-level submenu SVG chevron icon.
45
47
  *
48
+ * @since 5.9.0
49
+ *
46
50
  * @return string
47
51
  */
48
52
  function block_core_navigation_submenu_render_submenu_icon() {
@@ -52,6 +56,8 @@ function block_core_navigation_submenu_render_submenu_icon() {
52
56
  /**
53
57
  * Renders the `core/navigation-submenu` block.
54
58
  *
59
+ * @since 5.9.0
60
+ *
55
61
  * @param array $attributes The block attributes.
56
62
  * @param string $content The saved content.
57
63
  * @param WP_Block $block The parsed block.
@@ -238,6 +244,8 @@ function render_block_core_navigation_submenu( $attributes, $content, $block ) {
238
244
  /**
239
245
  * Register the navigation submenu block.
240
246
  *
247
+ * @since 5.9.0
248
+ *
241
249
  * @uses render_block_core_navigation_submenu()
242
250
  * @throws WP_Error An WP_Error exception parsing the block definition.
243
251
  */