@wordpress/block-library 6.0.14 → 6.0.17

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 (114) hide show
  1. package/build/group/edit.native.js +1 -1
  2. package/build/group/edit.native.js.map +1 -1
  3. package/build/group/index.js +3 -1
  4. package/build/group/index.js.map +1 -1
  5. package/build/navigation/deprecated.js +1 -3
  6. package/build/navigation/deprecated.js.map +1 -1
  7. package/build/navigation/edit/index.js +100 -44
  8. package/build/navigation/edit/index.js.map +1 -1
  9. package/build/navigation/edit/navigation-menu-selector.js +3 -2
  10. package/build/navigation/edit/navigation-menu-selector.js.map +1 -1
  11. package/build/navigation/edit/placeholder/index.js +15 -7
  12. package/build/navigation/edit/placeholder/index.js.map +1 -1
  13. package/build/navigation/edit/responsive-wrapper.js +9 -7
  14. package/build/navigation/edit/responsive-wrapper.js.map +1 -1
  15. package/build/navigation/edit/unsaved-inner-blocks.js +3 -11
  16. package/build/navigation/edit/unsaved-inner-blocks.js.map +1 -1
  17. package/build/navigation/edit/use-navigation-notice.js +54 -0
  18. package/build/navigation/edit/use-navigation-notice.js.map +1 -0
  19. package/build/navigation/index.js +1 -2
  20. package/build/navigation/index.js.map +1 -1
  21. package/build/navigation/use-navigation-menu.js +9 -2
  22. package/build/navigation/use-navigation-menu.js.map +1 -1
  23. package/build/navigation/view.js +12 -7
  24. package/build/navigation/view.js.map +1 -1
  25. package/build/post-template/edit.js +54 -13
  26. package/build/post-template/edit.js.map +1 -1
  27. package/build/site-logo/edit.js +9 -6
  28. package/build/site-logo/edit.js.map +1 -1
  29. package/build/site-logo/index.js +0 -3
  30. package/build/site-logo/index.js.map +1 -1
  31. package/build/template-part/edit/index.js +7 -1
  32. package/build/template-part/edit/index.js.map +1 -1
  33. package/build-module/group/edit.native.js +1 -1
  34. package/build-module/group/edit.native.js.map +1 -1
  35. package/build-module/group/index.js +3 -1
  36. package/build-module/group/index.js.map +1 -1
  37. package/build-module/navigation/deprecated.js +1 -3
  38. package/build-module/navigation/deprecated.js.map +1 -1
  39. package/build-module/navigation/edit/index.js +98 -44
  40. package/build-module/navigation/edit/index.js.map +1 -1
  41. package/build-module/navigation/edit/navigation-menu-selector.js +3 -2
  42. package/build-module/navigation/edit/navigation-menu-selector.js.map +1 -1
  43. package/build-module/navigation/edit/placeholder/index.js +15 -7
  44. package/build-module/navigation/edit/placeholder/index.js.map +1 -1
  45. package/build-module/navigation/edit/responsive-wrapper.js +9 -7
  46. package/build-module/navigation/edit/responsive-wrapper.js.map +1 -1
  47. package/build-module/navigation/edit/unsaved-inner-blocks.js +4 -13
  48. package/build-module/navigation/edit/unsaved-inner-blocks.js.map +1 -1
  49. package/build-module/navigation/edit/use-navigation-notice.js +44 -0
  50. package/build-module/navigation/edit/use-navigation-notice.js.map +1 -0
  51. package/build-module/navigation/index.js +1 -2
  52. package/build-module/navigation/index.js.map +1 -1
  53. package/build-module/navigation/use-navigation-menu.js +9 -2
  54. package/build-module/navigation/use-navigation-menu.js.map +1 -1
  55. package/build-module/navigation/view.js +12 -7
  56. package/build-module/navigation/view.js.map +1 -1
  57. package/build-module/post-template/edit.js +54 -15
  58. package/build-module/post-template/edit.js.map +1 -1
  59. package/build-module/site-logo/edit.js +9 -6
  60. package/build-module/site-logo/edit.js.map +1 -1
  61. package/build-module/site-logo/index.js +0 -3
  62. package/build-module/site-logo/index.js.map +1 -1
  63. package/build-module/template-part/edit/index.js +6 -1
  64. package/build-module/template-part/edit/index.js.map +1 -1
  65. package/build-style/common-rtl.css +10 -0
  66. package/build-style/common.css +10 -0
  67. package/build-style/editor-rtl.css +13 -11
  68. package/build-style/editor.css +13 -11
  69. package/build-style/navigation/editor-rtl.css +2 -0
  70. package/build-style/navigation/editor.css +2 -0
  71. package/build-style/navigation/style-rtl.css +56 -24
  72. package/build-style/navigation/style.css +56 -24
  73. package/build-style/post-comments/style-rtl.css +0 -1
  74. package/build-style/post-comments/style.css +0 -1
  75. package/build-style/site-logo/editor-rtl.css +1 -11
  76. package/build-style/site-logo/editor.css +1 -11
  77. package/build-style/site-logo/style-rtl.css +3 -1
  78. package/build-style/site-logo/style.css +3 -1
  79. package/build-style/style-rtl.css +69 -26
  80. package/build-style/style.css +69 -26
  81. package/package.json +14 -14
  82. package/src/common.scss +12 -0
  83. package/src/editor.scss +12 -0
  84. package/src/gallery/index.php +1 -1
  85. package/src/group/block.json +3 -1
  86. package/src/group/edit.native.js +1 -1
  87. package/src/home-link/index.php +1 -1
  88. package/src/navigation/block.json +1 -2
  89. package/src/navigation/deprecated.js +0 -2
  90. package/src/navigation/edit/index.js +153 -55
  91. package/src/navigation/edit/navigation-menu-selector.js +19 -13
  92. package/src/navigation/edit/placeholder/index.js +40 -24
  93. package/src/navigation/edit/responsive-wrapper.js +10 -7
  94. package/src/navigation/edit/unsaved-inner-blocks.js +13 -25
  95. package/src/navigation/edit/use-navigation-notice.js +37 -0
  96. package/src/navigation/editor.scss +2 -0
  97. package/src/navigation/index.php +19 -8
  98. package/src/navigation/style.scss +82 -32
  99. package/src/navigation/use-navigation-menu.js +20 -0
  100. package/src/navigation/view.js +13 -7
  101. package/src/navigation-link/index.php +1 -1
  102. package/src/navigation-submenu/index.php +9 -3
  103. package/src/page-list/index.php +9 -4
  104. package/src/post-comments/index.php +6 -4
  105. package/src/post-comments/style.scss +0 -1
  106. package/src/post-comments-form/index.php +6 -4
  107. package/src/post-template/edit.js +54 -17
  108. package/src/site-logo/block.json +0 -3
  109. package/src/site-logo/edit.js +6 -5
  110. package/src/site-logo/editor.scss +1 -15
  111. package/src/site-logo/index.php +0 -4
  112. package/src/site-logo/style.scss +3 -1
  113. package/src/template-part/edit/index.js +6 -1
  114. package/src/template-part/index.php +5 -2
@@ -452,14 +452,24 @@ function render_block_core_navigation( $attributes, $content, $block ) {
452
452
 
453
453
  }
454
454
 
455
+ $layout_justification = array(
456
+ 'left' => 'items-justified-left',
457
+ 'right' => 'items-justified-right',
458
+ 'center' => 'items-justified-center',
459
+ 'space-between' => 'items-justified-space-between',
460
+ );
461
+
455
462
  // Restore legacy classnames for submenu positioning.
456
463
  $layout_class = '';
457
464
  if ( isset( $attributes['layout']['justifyContent'] ) ) {
458
- if ( 'right' === $attributes['layout']['justifyContent'] ) {
459
- $layout_class .= 'items-justified-right';
460
- } elseif ( 'space-between' === $attributes['layout']['justifyContent'] ) {
461
- $layout_class .= 'items-justified-space-between';
462
- }
465
+ $layout_class .= $layout_justification[ $attributes['layout']['justifyContent'] ];
466
+ }
467
+ if ( isset( $attributes['layout']['orientation'] ) && 'vertical' === $attributes['layout']['orientation'] ) {
468
+ $layout_class .= ' is-vertical';
469
+ }
470
+
471
+ if ( isset( $attributes['layout']['flexWrap'] ) && 'nowrap' === $attributes['layout']['flexWrap'] ) {
472
+ $layout_class .= ' no-wrap';
463
473
  }
464
474
 
465
475
  $colors = block_core_navigation_build_css_colors( $attributes );
@@ -528,10 +538,10 @@ function render_block_core_navigation( $attributes, $content, $block ) {
528
538
  );
529
539
 
530
540
  $responsive_container_markup = sprintf(
531
- '<button aria-expanded="false" aria-haspopup="true" aria-label="%3$s" class="%6$s" data-micromodal-trigger="modal-%1$s"><svg width="24" height="24" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" role="img" aria-hidden="true" focusable="false"><rect x="4" y="7.5" width="16" height="1.5" /><rect x="4" y="15" width="16" height="1.5" /></svg></button>
541
+ '<button aria-haspopup="true" aria-label="%3$s" class="%6$s" data-micromodal-trigger="modal-%1$s"><svg width="24" height="24" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" role="img" aria-hidden="true" focusable="false"><rect x="4" y="7.5" width="16" height="1.5" /><rect x="4" y="15" width="16" height="1.5" /></svg></button>
532
542
  <div class="%5$s" style="%7$s" id="modal-%1$s">
533
543
  <div class="wp-block-navigation__responsive-close" tabindex="-1" data-micromodal-close>
534
- <div class="wp-block-navigation__responsive-dialog" role="dialog" aria-modal="true" aria-labelledby="modal-%1$s-title" >
544
+ <div class="wp-block-navigation__responsive-dialog" aria-label="%8$s">
535
545
  <button aria-label="%4$s" data-micromodal-close class="wp-block-navigation__responsive-container-close"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24" role="img" aria-hidden="true" focusable="false"><path d="M13 11.8l6.1-6.3-1-1-6.1 6.2-6.1-6.2-1 1 6.1 6.3-6.5 6.7 1 1 6.5-6.6 6.5 6.6 1-1z"></path></svg></button>
536
546
  <div class="wp-block-navigation__responsive-container-content" id="modal-%1$s-content">
537
547
  %2$s
@@ -545,7 +555,8 @@ function render_block_core_navigation( $attributes, $content, $block ) {
545
555
  __( 'Close menu' ), // Close button label.
546
556
  implode( ' ', $responsive_container_classes ),
547
557
  implode( ' ', $open_button_classes ),
548
- $colors['overlay_inline_styles']
558
+ $colors['overlay_inline_styles'],
559
+ __( 'Menu' )
549
560
  );
550
561
 
551
562
  return sprintf(
@@ -6,6 +6,10 @@
6
6
  // - .wp-block-navigation-item targets the menu item itself.
7
7
  // - .wp-block-navigation-item__content targets the link inside a menu item.
8
8
  // - .wp-block-navigation__submenu-icon targets the chevron icon indicating submenus.
9
+
10
+ // Size of burger and close icons.
11
+ $navigation-icon-size: 24px;
12
+
9
13
  .wp-block-navigation {
10
14
  position: relative;
11
15
 
@@ -102,6 +106,45 @@
102
106
  height: inherit;
103
107
  }
104
108
  }
109
+
110
+ // Custom properties for layout style cascade: default values.
111
+ --navigation-layout-justification-setting: flex-start;
112
+ --navigation-layout-direction: row;
113
+ --navigation-layout-wrap: wrap;
114
+ --navigation-layout-justify: flex-start;
115
+ --navigation-layout-align: center;
116
+
117
+ &.is-vertical {
118
+ --navigation-layout-direction: column;
119
+ --navigation-layout-justify: initial;
120
+ }
121
+
122
+ &.no-wrap {
123
+ --navigation-layout-wrap: nowrap;
124
+ }
125
+
126
+ &.items-justified-center {
127
+ --navigation-layout-justification-setting: center;
128
+ --navigation-layout-justify: center;
129
+
130
+ &.is-vertical {
131
+ --navigation-layout-align: center;
132
+ }
133
+ }
134
+
135
+ &.items-justified-right {
136
+ --navigation-layout-justification-setting: flex-end;
137
+ --navigation-layout-justify: flex-end;
138
+
139
+ &.is-vertical {
140
+ --navigation-layout-align: flex-end;
141
+ }
142
+ }
143
+
144
+ &.items-justified-space-between {
145
+ --navigation-layout-justification-setting: space-between;
146
+ --navigation-layout-justify: space-between;
147
+ }
105
148
  }
106
149
 
107
150
  // Styles for submenu flyout.
@@ -347,10 +390,10 @@ button.wp-block-navigation-item__content {
347
390
  // Navigation block inner container.
348
391
  .wp-block-navigation__container {
349
392
  display: flex;
350
- flex-wrap: var(--layout-wrap, wrap);
351
- flex-direction: var(--layout-direction, initial);
352
- justify-content: var(--layout-justify, initial);
353
- align-items: var(--layout-align, initial);
393
+ flex-wrap: var(--navigation-layout-wrap, wrap);
394
+ flex-direction: var(--navigation-layout-direction, initial);
395
+ justify-content: var(--navigation-layout-justify, initial);
396
+ align-items: var(--navigation-layout-align, initial);
354
397
 
355
398
  // Reset the default list styles
356
399
  list-style: none;
@@ -384,10 +427,10 @@ button.wp-block-navigation-item__content {
384
427
 
385
428
  .wp-block-navigation__responsive-container-content {
386
429
  display: flex;
387
- flex-wrap: var(--layout-wrap, wrap);
388
- flex-direction: var(--layout-direction, initial);
389
- justify-content: var(--layout-justify, initial);
390
- align-items: var(--layout-align, initial);
430
+ flex-wrap: var(--navigation-layout-wrap, wrap);
431
+ flex-direction: var(--navigation-layout-direction, initial);
432
+ justify-content: var(--navigation-layout-justify, initial);
433
+ align-items: var(--navigation-layout-align, initial);
391
434
  }
392
435
 
393
436
  // If the responsive wrapper is present but overlay is not open,
@@ -405,6 +448,10 @@ button.wp-block-navigation-item__content {
405
448
  &.is-menu-open {
406
449
  display: flex; // Needs to be set to override "none".
407
450
  flex-direction: column;
451
+ background-color: inherit;
452
+
453
+ // Use em units to apply padding, so themes can more easily style this in various ways.
454
+ padding: 2em;
408
455
 
409
456
  // Allow modal to scroll.
410
457
  overflow: auto;
@@ -412,29 +459,30 @@ button.wp-block-navigation-item__content {
412
459
  // Give it a z-index just higher than the adminbar.
413
460
  z-index: 100000;
414
461
 
415
- // Add extra top padding so items don't conflict with close button.
416
- padding: 72px 24px 24px 24px;
417
- background-color: inherit;
418
-
419
462
  .wp-block-navigation__responsive-container-content {
463
+ // Add padding above to accommodate close button.
464
+ padding-top: calc(2em + #{ $navigation-icon-size });
465
+
466
+ // Don't crop the focus style.
467
+ overflow: visible;
468
+
420
469
  // Override the container flex layout settings
421
470
  // because we want overlay menu to always display
422
471
  // as a column.
423
472
  display: flex;
424
473
  flex-direction: column;
474
+ flex-wrap: nowrap;
475
+
425
476
  // Inherit alignment settings from container.
426
- align-items: var(--layout-justification-setting, inherit);
477
+ align-items: var(--navigation-layout-justification-setting, inherit);
427
478
 
428
479
  // Always align the contents of the menu to the top.
429
480
  &,
481
+ .wp-block-page-list,
430
482
  .wp-block-navigation__container {
431
483
  justify-content: flex-start;
432
484
  }
433
485
 
434
- // Allow menu to scroll.
435
- overflow: auto;
436
- padding: 0;
437
-
438
486
  .wp-block-navigation__submenu-icon {
439
487
  display: none;
440
488
  }
@@ -453,20 +501,19 @@ button.wp-block-navigation-item__content {
453
501
  // Position and style.
454
502
  position: static;
455
503
  border: none;
456
- padding-left: 32px;
457
- padding-right: 32px;
504
+ padding-left: 2em;
505
+ padding-right: 2em;
458
506
  }
459
507
 
460
508
  // Space unfolded items using gap and padding for submenus.
461
509
  .wp-block-navigation__submenu-container,
462
510
  .wp-block-navigation__container {
463
511
  gap: var(--wp--style--block-gap, 2em);
512
+ }
464
513
 
465
- // Apply top padding to nested submenus.
466
- .wp-block-navigation__submenu-container,
467
- .wp-block-navigation__container {
468
- padding-top: var(--wp--style--block-gap, 2em);
469
- }
514
+ // Apply top padding to nested submenus.
515
+ .wp-block-navigation__submenu-container {
516
+ padding-top: var(--wp--style--block-gap, 2em);
470
517
  }
471
518
 
472
519
  // A default padding is added to submenu items. It's not appropriate inside the modal.
@@ -481,7 +528,7 @@ button.wp-block-navigation-item__content {
481
528
  display: flex;
482
529
  flex-direction: column;
483
530
  // Inherit alignment settings from container.
484
- align-items: var(--layout-justification-setting, initial);
531
+ align-items: var(--navigation-layout-justification-setting, initial);
485
532
  }
486
533
  }
487
534
 
@@ -547,8 +594,8 @@ button.wp-block-navigation-item__content {
547
594
  fill: currentColor;
548
595
  pointer-events: none;
549
596
  display: block;
550
- width: 24px;
551
- height: 24px;
597
+ width: $navigation-icon-size;
598
+ height: $navigation-icon-size;
552
599
  }
553
600
  }
554
601
 
@@ -566,8 +613,8 @@ button.wp-block-navigation-item__content {
566
613
  // Button to close the menus.
567
614
  .wp-block-navigation__responsive-container-close {
568
615
  position: absolute;
569
- top: 24px;
570
- right: 24px;
616
+ top: 0;
617
+ right: 0;
571
618
  z-index: 2; // Needs to be above the modal z index itself.
572
619
  }
573
620
 
@@ -579,11 +626,14 @@ button.wp-block-navigation-item__content {
579
626
  .is-menu-open .wp-block-navigation__responsive-close,
580
627
  .is-menu-open .wp-block-navigation__responsive-dialog,
581
628
  .is-menu-open .wp-block-navigation__responsive-container-content {
582
- width: 100%;
583
- height: 100%;
629
+ box-sizing: border-box;
584
630
  }
585
631
 
632
+ .wp-block-navigation__responsive-dialog {
633
+ position: relative;
634
+ }
635
+
636
+ // Prevent scrolling of the parent content when the modal is open.
586
637
  html.has-modal-open {
587
638
  overflow: hidden;
588
639
  }
589
-
@@ -12,6 +12,7 @@ export default function useNavigationMenu( ref ) {
12
12
  getEditedEntityRecord,
13
13
  getEntityRecords,
14
14
  hasFinishedResolution,
15
+ canUser,
15
16
  } = select( coreStore );
16
17
 
17
18
  const navigationMenuSingleArgs = [
@@ -64,6 +65,25 @@ export default function useNavigationMenu( ref ) {
64
65
  ),
65
66
  navigationMenu,
66
67
  navigationMenus,
68
+ canUserUpdateNavigationEntity: ref
69
+ ? canUser( 'update', 'navigation', ref )
70
+ : undefined,
71
+ hasResolvedCanUserUpdateNavigationEntity: hasFinishedResolution(
72
+ 'canUser',
73
+ [ 'update', 'navigation', ref ]
74
+ ),
75
+ canUserDeleteNavigationEntity: ref
76
+ ? canUser( 'delete', 'navigation', ref )
77
+ : undefined,
78
+ hasResolvedCanUserDeleteNavigationEntity: hasFinishedResolution(
79
+ 'canUser',
80
+ [ 'delete', 'navigation', ref ]
81
+ ),
82
+ canUserCreateNavigation: canUser( 'create', 'navigation' ),
83
+ hasResolvedCanUserCreateNavigation: hasFinishedResolution(
84
+ 'canUser',
85
+ [ 'create', 'navigation' ]
86
+ ),
67
87
  };
68
88
  },
69
89
  [ ref ]
@@ -5,16 +5,22 @@ import MicroModal from 'micromodal';
5
5
 
6
6
  // Responsive navigation toggle.
7
7
  function navigationToggleModal( modal ) {
8
- const triggerButton = document.querySelector(
9
- `button[data-micromodal-trigger="${ modal.id }"]`
8
+ const dialogContainer = document.querySelector(
9
+ `.wp-block-navigation__responsive-dialog`
10
10
  );
11
- const closeButton = modal.querySelector( 'button[data-micromodal-close]' );
12
- // Use aria-hidden to determine the status of the modal, as this attribute is
13
- // managed by micromodal.
11
+
14
12
  const isHidden = 'true' === modal.getAttribute( 'aria-hidden' );
15
- triggerButton.setAttribute( 'aria-expanded', ! isHidden );
16
- closeButton.setAttribute( 'aria-expanded', ! isHidden );
13
+
17
14
  modal.classList.toggle( 'has-modal-open', ! isHidden );
15
+ dialogContainer.toggleAttribute( 'aria-modal', ! isHidden );
16
+
17
+ if ( isHidden ) {
18
+ dialogContainer.removeAttribute( 'role' );
19
+ dialogContainer.removeAttribute( 'aria-modal' );
20
+ } else {
21
+ dialogContainer.setAttribute( 'role', 'dialog' );
22
+ dialogContainer.setAttribute( 'aria-modal', 'true' );
23
+ }
18
24
 
19
25
  // Add a class to indicate the modal is open.
20
26
  const htmlElement = document.documentElement;
@@ -98,7 +98,7 @@ function block_core_navigation_link_build_css_font_sizes( $context ) {
98
98
  $font_sizes['css_classes'][] = sprintf( 'has-%s-font-size', $context['fontSize'] );
99
99
  } elseif ( $has_custom_font_size ) {
100
100
  // Add the custom font size inline style.
101
- $font_sizes['inline_styles'] = sprintf( 'font-size: %spx;', $context['style']['typography']['fontSize'] );
101
+ $font_sizes['inline_styles'] = sprintf( 'font-size: %s;', $context['style']['typography']['fontSize'] );
102
102
  }
103
103
 
104
104
  return $font_sizes;
@@ -98,7 +98,7 @@ function block_core_navigation_submenu_build_css_font_sizes( $context ) {
98
98
  $font_sizes['css_classes'][] = sprintf( 'has-%s-font-size', $context['fontSize'] );
99
99
  } elseif ( $has_custom_font_size ) {
100
100
  // Add the custom font size inline style.
101
- $font_sizes['inline_styles'] = sprintf( 'font-size: %spx;', $context['style']['typography']['fontSize'] );
101
+ $font_sizes['inline_styles'] = sprintf( 'font-size: %s;', $context['style']['typography']['fontSize'] );
102
102
  }
103
103
 
104
104
  return $font_sizes;
@@ -188,6 +188,12 @@ function render_block_core_navigation_submenu( $attributes, $content, $block ) {
188
188
  );
189
189
  }
190
190
 
191
+ $aria_label = sprintf(
192
+ /* translators: Accessibility text. %s: Parent page title. */
193
+ __( '%s submenu' ),
194
+ $label
195
+ );
196
+
191
197
  $html = '<li ' . $wrapper_attributes . '>';
192
198
 
193
199
  // If Submenus open on hover, we render an anchor tag with attributes.
@@ -226,11 +232,11 @@ function render_block_core_navigation_submenu( $attributes, $content, $block ) {
226
232
  if ( $show_submenu_indicators ) {
227
233
  // The submenu icon is rendered in a button here
228
234
  // so that there's a clickable elment to open the submenu.
229
- $html .= '<button aria-label="' . $label . ' ' . __( 'submenu', 'gutenberg' ) . '" class="wp-block-navigation__submenu-icon wp-block-navigation-submenu__toggle" aria-expanded="false">' . block_core_navigation_submenu_render_submenu_icon() . '</button>';
235
+ $html .= '<button aria-label="' . $aria_label . '" class="wp-block-navigation__submenu-icon wp-block-navigation-submenu__toggle" aria-expanded="false">' . block_core_navigation_submenu_render_submenu_icon() . '</button>';
230
236
  }
231
237
  } else {
232
238
  // If menus open on click, we render the parent as a button.
233
- $html .= '<button aria-label="' . $label . ' ' . __( 'submenu', 'gutenberg' ) . '" class="wp-block-navigation-item__content wp-block-navigation-submenu__toggle" aria-expanded="false">';
239
+ $html .= '<button aria-label="' . $aria_label . '" class="wp-block-navigation-item__content wp-block-navigation-submenu__toggle" aria-expanded="false">';
234
240
 
235
241
  // Wrap title with span to isolate it from submenu icon.
236
242
  $html .= '<span class="wp-block-navigation-item__label">';
@@ -119,7 +119,7 @@ function block_core_page_list_build_css_font_sizes( $context ) {
119
119
  $font_sizes['css_classes'][] = sprintf( 'has-%s-font-size', $context['fontSize'] );
120
120
  } elseif ( $has_custom_font_size ) {
121
121
  // Add the custom font size inline style.
122
- $font_sizes['inline_styles'] = sprintf( 'font-size: %spx;', $context['style']['typography']['fontSize'] );
122
+ $font_sizes['inline_styles'] = sprintf( 'font-size: %s;', $context['style']['typography']['fontSize'] );
123
123
  }
124
124
 
125
125
  return $font_sizes;
@@ -173,12 +173,17 @@ function block_core_page_list_render_nested_page_list( $open_submenus_on_click,
173
173
  }
174
174
  }
175
175
 
176
- $title = wp_kses( $page['title'], wp_kses_allowed_html( 'post' ) );
176
+ $title = wp_kses( $page['title'], wp_kses_allowed_html( 'post' ) );
177
+ $aria_label = sprintf(
178
+ /* translators: Accessibility text. %s: Parent page title. */
179
+ __( '%s submenu' ),
180
+ $title
181
+ );
177
182
 
178
183
  $markup .= '<li class="wp-block-pages-list__item' . $css_class . '"' . $style_attribute . '>';
179
184
 
180
185
  if ( isset( $page['children'] ) && $is_navigation_child && $open_submenus_on_click ) {
181
- $markup .= '<button aria-label="' . $title . ' ' . __( 'submenu', 'gutenberg' ) . '" class="' . $navigation_child_content_class . ' wp-block-navigation-submenu__toggle" aria-expanded="false">' . $title . '<span class="wp-block-page-list__submenu-icon wp-block-navigation__submenu-icon"><svg xmlns="http://www.w3.org/2000/svg" width="12" height="12" viewBox="0 0 12 12" fill="none" role="img" aria-hidden="true" focusable="false"><path d="M1.50002 4L6.00002 8L10.5 4" stroke-width="1.5"></path></svg></span>' .
186
+ $markup .= '<button aria-label="' . $aria_label . '" class="' . $navigation_child_content_class . ' wp-block-navigation-submenu__toggle" aria-expanded="false">' . $title . '<span class="wp-block-page-list__submenu-icon wp-block-navigation__submenu-icon"><svg xmlns="http://www.w3.org/2000/svg" width="12" height="12" viewBox="0 0 12 12" fill="none" role="img" aria-hidden="true" focusable="false"><path d="M1.50002 4L6.00002 8L10.5 4" stroke-width="1.5"></path></svg></span>' .
182
187
  '</button>';
183
188
  } else {
184
189
  $markup .= '<a class="wp-block-pages-list__item__link' . $navigation_child_content_class . '" href="' . esc_url( $page['link'] ) . '"' . $aria_current . '>' . $title . '</a>';
@@ -186,7 +191,7 @@ function block_core_page_list_render_nested_page_list( $open_submenus_on_click,
186
191
 
187
192
  if ( isset( $page['children'] ) ) {
188
193
  if ( $is_navigation_child && $show_submenu_icons && ! $open_submenus_on_click ) {
189
- $markup .= '<button aria-label="' . $title . ' ' . __( 'submenu', 'gutenberg' ) . '" class="wp-block-navigation__submenu-icon wp-block-navigation-submenu__toggle" aria-expanded="false">';
194
+ $markup .= '<button aria-label="' . $aria_label . '" class="wp-block-navigation__submenu-icon wp-block-navigation-submenu__toggle" aria-expanded="false">';
190
195
  $markup .= '<span class="wp-block-page-list__submenu-icon wp-block-navigation__submenu-icon"><svg xmlns="http://www.w3.org/2000/svg" width="12" height="12" viewBox="0 0 12 12" fill="none" role="img" aria-hidden="true" focusable="false"><path d="M1.50002 4L6.00002 8L10.5 4" stroke-width="1.5"></path></svg></span>';
191
196
  $markup .= '</button>';
192
197
  }
@@ -74,10 +74,12 @@ add_action( 'init', 'register_block_core_post_comments' );
74
74
  *
75
75
  * @return array Returns the modified fields.
76
76
  */
77
- function gutenberg_post_comments_block_form_defaults( $fields ) {
78
- $fields['submit_button'] = '<input name="%1$s" type="submit" id="%2$s" class="%3$s wp-block-button__link" value="%4$s" />';
79
- $fields['submit_field'] = '<p class="form-submit wp-block-button">%1$s %2$s</p>';
77
+ function post_comments_block_form_defaults( $fields ) {
78
+ if ( wp_is_block_theme() ) {
79
+ $fields['submit_button'] = '<input name="%1$s" type="submit" id="%2$s" class="%3$s wp-block-button__link" value="%4$s" />';
80
+ $fields['submit_field'] = '<p class="form-submit wp-block-button">%1$s %2$s</p>';
81
+ }
80
82
 
81
83
  return $fields;
82
84
  }
83
- add_filter( 'comment_form_defaults', 'gutenberg_post_comments_block_form_defaults' );
85
+ add_filter( 'comment_form_defaults', 'post_comments_block_form_defaults' );
@@ -29,7 +29,6 @@
29
29
 
30
30
  .comment-author {
31
31
  line-height: 1.5;
32
- margin-left: -3.25em;
33
32
 
34
33
  .avatar {
35
34
  border-radius: 1.5em;
@@ -54,10 +54,12 @@ add_action( 'init', 'register_block_core_post_comments_form' );
54
54
  *
55
55
  * @return array Returns the modified fields.
56
56
  */
57
- function gutenberg_comment_form_block_form_defaults( $fields ) {
58
- $fields['submit_button'] = '<input name="%1$s" type="submit" id="%2$s" class="%3$s wp-block-button__link" value="%4$s" />';
59
- $fields['submit_field'] = '<p class="form-submit wp-block-button">%1$s %2$s</p>';
57
+ function post_comments_form_block_form_defaults( $fields ) {
58
+ if ( wp_is_block_theme() ) {
59
+ $fields['submit_button'] = '<input name="%1$s" type="submit" id="%2$s" class="%3$s wp-block-button__link" value="%4$s" />';
60
+ $fields['submit_field'] = '<p class="form-submit wp-block-button">%1$s %2$s</p>';
61
+ }
60
62
 
61
63
  return $fields;
62
64
  }
63
- add_filter( 'comment_form_defaults', 'gutenberg_comment_form_block_form_defaults' );
65
+ add_filter( 'comment_form_defaults', 'post_comments_form_block_form_defaults' );
@@ -6,12 +6,12 @@ import classnames from 'classnames';
6
6
  /**
7
7
  * WordPress dependencies
8
8
  */
9
- import { useState, useMemo } from '@wordpress/element';
9
+ import { memo, useMemo, useState } from '@wordpress/element';
10
10
  import { useSelect } from '@wordpress/data';
11
11
  import { __ } from '@wordpress/i18n';
12
12
  import {
13
13
  BlockContextProvider,
14
- BlockPreview,
14
+ __experimentalUseBlockPreview as useBlockPreview,
15
15
  useBlockProps,
16
16
  useInnerBlocksProps,
17
17
  store as blockEditorStore,
@@ -30,6 +30,39 @@ function PostTemplateInnerBlocks() {
30
30
  return <li { ...innerBlocksProps } />;
31
31
  }
32
32
 
33
+ function PostTemplateBlockPreview( {
34
+ blocks,
35
+ blockContextId,
36
+ isHidden,
37
+ setActiveBlockContextId,
38
+ } ) {
39
+ const blockPreviewProps = useBlockPreview( {
40
+ blocks,
41
+ } );
42
+
43
+ const handleOnClick = () => {
44
+ setActiveBlockContextId( blockContextId );
45
+ };
46
+
47
+ const style = {
48
+ display: isHidden ? 'none' : undefined,
49
+ };
50
+
51
+ return (
52
+ <li
53
+ { ...blockPreviewProps }
54
+ tabIndex={ 0 }
55
+ // eslint-disable-next-line jsx-a11y/no-noninteractive-element-to-interactive-role
56
+ role="button"
57
+ onClick={ handleOnClick }
58
+ onKeyPress={ handleOnClick }
59
+ style={ style }
60
+ />
61
+ );
62
+ }
63
+
64
+ const MemoizedPostTemplateBlockPreview = memo( PostTemplateBlockPreview );
65
+
33
66
  export default function PostTemplateEdit( {
34
67
  clientId,
35
68
  context: {
@@ -53,7 +86,7 @@ export default function PostTemplateEdit( {
53
86
  },
54
87
  } ) {
55
88
  const [ { page } ] = queryContext;
56
- const [ activeBlockContext, setActiveBlockContext ] = useState();
89
+ const [ activeBlockContextId, setActiveBlockContextId ] = useState();
57
90
 
58
91
  const { posts, blocks } = useSelect(
59
92
  ( select ) => {
@@ -115,7 +148,6 @@ export default function PostTemplateEdit( {
115
148
  templateSlug,
116
149
  ]
117
150
  );
118
-
119
151
  const blockContexts = useMemo(
120
152
  () =>
121
153
  posts?.map( ( post ) => ( {
@@ -144,6 +176,10 @@ export default function PostTemplateEdit( {
144
176
  return <p { ...blockProps }> { __( 'No results found.' ) }</p>;
145
177
  }
146
178
 
179
+ // To avoid flicker when switching active block contexts, a preview is rendered
180
+ // for each block context, but the preview for the active block context is hidden.
181
+ // This ensures that when it is displayed again, the cached rendering of the
182
+ // block preview is used, instead of having to re-render the preview from scratch.
147
183
  return (
148
184
  <ul { ...blockProps }>
149
185
  { blockContexts &&
@@ -152,20 +188,21 @@ export default function PostTemplateEdit( {
152
188
  key={ blockContext.postId }
153
189
  value={ blockContext }
154
190
  >
155
- { blockContext ===
156
- ( activeBlockContext || blockContexts[ 0 ] ) ? (
191
+ { blockContext.postId ===
192
+ ( activeBlockContextId ||
193
+ blockContexts[ 0 ]?.postId ) ? (
157
194
  <PostTemplateInnerBlocks />
158
- ) : (
159
- <li>
160
- <BlockPreview
161
- blocks={ blocks }
162
- __experimentalLive
163
- __experimentalOnClick={ () =>
164
- setActiveBlockContext( blockContext )
165
- }
166
- />
167
- </li>
168
- ) }
195
+ ) : null }
196
+ <MemoizedPostTemplateBlockPreview
197
+ blocks={ blocks }
198
+ blockContextId={ blockContext.postId }
199
+ setActiveBlockContextId={ setActiveBlockContextId }
200
+ isHidden={
201
+ blockContext.postId ===
202
+ ( activeBlockContextId ||
203
+ blockContexts[ 0 ]?.postId )
204
+ }
205
+ />
169
206
  </BlockContextProvider>
170
207
  ) ) }
171
208
  </ul>
@@ -6,9 +6,6 @@
6
6
  "description": "Display a graphic to represent this site. Update the block, and the changes apply everywhere it’s used. This is different than the site icon, which is the smaller image visible in your dashboard, browser tabs, etc used to help others recognize this site.",
7
7
  "textdomain": "default",
8
8
  "attributes": {
9
- "align": {
10
- "type": "string"
11
- },
12
9
  "width": {
13
10
  "type": "number"
14
11
  },
@@ -142,7 +142,11 @@ const SiteLogo = ( {
142
142
  return <div style={ { width, height } }>{ imgWrapper }</div>;
143
143
  }
144
144
 
145
- const currentWidth = width || imageWidthWithinContainer;
145
+ // Set the default width to a responsible size.
146
+ // Note that this width is also set in the attached frontend CSS file.
147
+ const defaultWidth = 120;
148
+
149
+ const currentWidth = width || defaultWidth;
146
150
  const ratio = naturalWidth / naturalHeight;
147
151
  const currentHeight = currentWidth / ratio;
148
152
  const minWidth = naturalWidth < naturalHeight ? MIN_SIZE : MIN_SIZE * ratio;
@@ -160,10 +164,6 @@ const SiteLogo = ( {
160
164
  // becomes available.
161
165
  const maxWidthBuffer = maxWidth * 2.5;
162
166
 
163
- // Set the default width to a responsible size.
164
- // Note that this width is also set in the attached CSS file.
165
- const defaultWidth = 120;
166
-
167
167
  let showRightHandle = false;
168
168
  let showLeftHandle = false;
169
169
 
@@ -383,6 +383,7 @@ export default function LogoEdit( {
383
383
  const onRemoveLogo = () => {
384
384
  setLogo( null );
385
385
  setLogoUrl( undefined );
386
+ setAttributes( { width: undefined } );
386
387
  };
387
388
 
388
389
  const { createErrorNotice } = useDispatch( noticesStore );
@@ -1,7 +1,7 @@
1
1
  .wp-block[data-align="center"] > .wp-block-site-logo {
2
+ display: table;
2
3
  margin-left: auto;
3
4
  margin-right: auto;
4
- text-align: center;
5
5
  }
6
6
 
7
7
  .wp-block-site-logo {
@@ -10,20 +10,6 @@
10
10
  pointer-events: none;
11
11
  }
12
12
 
13
- &:not(.is-default-size) {
14
- display: table;
15
- }
16
-
17
- // Provide a sane starting point for the size.
18
- &.is-default-size {
19
- width: 120px;
20
-
21
- img {
22
- height: auto;
23
- width: 100%;
24
- }
25
- }
26
-
27
13
  .custom-logo-link {
28
14
  cursor: inherit;
29
15
 
@@ -48,10 +48,6 @@ function render_block_core_site_logo( $attributes ) {
48
48
  $classnames[] = $attributes['className'];
49
49
  }
50
50
 
51
- if ( ! empty( $attributes['align'] ) && in_array( $attributes['align'], array( 'center', 'left', 'right' ), true ) ) {
52
- $classnames[] = "align{$attributes['align']}";
53
- }
54
-
55
51
  if ( empty( $attributes['width'] ) ) {
56
52
  $classnames[] = 'is-default-size';
57
53
  }