@wordpress/block-library 7.14.0 → 7.14.1

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 (104) hide show
  1. package/build/button/edit.js +8 -3
  2. package/build/button/edit.js.map +1 -1
  3. package/build/column/index.js +1 -1
  4. package/build/cover/index.js +1 -1
  5. package/build/group/edit.js +0 -17
  6. package/build/group/edit.js.map +1 -1
  7. package/build/group/index.js +1 -7
  8. package/build/group/index.js.map +1 -1
  9. package/build/group/transforms.js +4 -1
  10. package/build/group/transforms.js.map +1 -1
  11. package/build/group/variations.js +2 -1
  12. package/build/group/variations.js.map +1 -1
  13. package/build/media-text/edit.js +25 -11
  14. package/build/media-text/edit.js.map +1 -1
  15. package/build/media-text/media-container.js +4 -3
  16. package/build/media-text/media-container.js.map +1 -1
  17. package/build/navigation/edit/overlay-menu-icon.js +0 -8
  18. package/build/navigation/edit/overlay-menu-icon.js.map +1 -1
  19. package/build/navigation/edit/overlay-menu-preview.js +0 -12
  20. package/build/navigation/edit/overlay-menu-preview.js.map +1 -1
  21. package/build/navigation-link/edit.js +8 -3
  22. package/build/navigation-link/edit.js.map +1 -1
  23. package/build/navigation-submenu/edit.js +8 -3
  24. package/build/navigation-submenu/edit.js.map +1 -1
  25. package/build/post-date/edit.js +10 -6
  26. package/build/post-date/edit.js.map +1 -1
  27. package/build/query/edit/index.js +23 -211
  28. package/build/query/edit/index.js.map +1 -1
  29. package/build/query/edit/query-content.js +169 -0
  30. package/build/query/edit/query-content.js.map +1 -0
  31. package/build/query/edit/query-placeholder.js +69 -6
  32. package/build/query/edit/query-placeholder.js.map +1 -1
  33. package/build/query/utils.js +40 -0
  34. package/build/query/utils.js.map +1 -1
  35. package/build/social-link/edit.js +8 -6
  36. package/build/social-link/edit.js.map +1 -1
  37. package/build/template-part/edit/selection-modal.js +2 -13
  38. package/build/template-part/edit/selection-modal.js.map +1 -1
  39. package/build-module/button/edit.js +7 -3
  40. package/build-module/button/edit.js.map +1 -1
  41. package/build-module/column/index.js +1 -1
  42. package/build-module/cover/index.js +1 -1
  43. package/build-module/group/edit.js +1 -19
  44. package/build-module/group/edit.js.map +1 -1
  45. package/build-module/group/index.js +1 -7
  46. package/build-module/group/index.js.map +1 -1
  47. package/build-module/group/transforms.js +4 -1
  48. package/build-module/group/transforms.js.map +1 -1
  49. package/build-module/group/variations.js +2 -1
  50. package/build-module/group/variations.js.map +1 -1
  51. package/build-module/media-text/edit.js +25 -11
  52. package/build-module/media-text/edit.js.map +1 -1
  53. package/build-module/media-text/media-container.js +4 -3
  54. package/build-module/media-text/media-container.js.map +1 -1
  55. package/build-module/navigation/edit/overlay-menu-icon.js +1 -9
  56. package/build-module/navigation/edit/overlay-menu-icon.js.map +1 -1
  57. package/build-module/navigation/edit/overlay-menu-preview.js +0 -12
  58. package/build-module/navigation/edit/overlay-menu-preview.js.map +1 -1
  59. package/build-module/navigation-link/edit.js +7 -3
  60. package/build-module/navigation-link/edit.js.map +1 -1
  61. package/build-module/navigation-submenu/edit.js +7 -3
  62. package/build-module/navigation-submenu/edit.js.map +1 -1
  63. package/build-module/post-date/edit.js +11 -7
  64. package/build-module/post-date/edit.js.map +1 -1
  65. package/build-module/query/edit/index.js +27 -208
  66. package/build-module/query/edit/index.js.map +1 -1
  67. package/build-module/query/edit/query-content.js +152 -0
  68. package/build-module/query/edit/query-content.js.map +1 -0
  69. package/build-module/query/edit/query-placeholder.js +67 -5
  70. package/build-module/query/edit/query-placeholder.js.map +1 -1
  71. package/build-module/query/utils.js +37 -0
  72. package/build-module/query/utils.js.map +1 -1
  73. package/build-module/social-link/edit.js +9 -7
  74. package/build-module/social-link/edit.js.map +1 -1
  75. package/build-module/template-part/edit/selection-modal.js +3 -14
  76. package/build-module/template-part/edit/selection-modal.js.map +1 -1
  77. package/package.json +14 -14
  78. package/src/button/edit.js +10 -2
  79. package/src/column/block.json +1 -1
  80. package/src/comments/index.php +1 -1
  81. package/src/cover/block.json +1 -1
  82. package/src/group/block.json +1 -7
  83. package/src/group/edit.js +2 -12
  84. package/src/group/transforms.js +1 -0
  85. package/src/group/variations.js +2 -1
  86. package/src/list/test/__snapshots__/edit.native.js.snap +8 -32
  87. package/src/list/test/edit.native.js +16 -68
  88. package/src/media-text/edit.js +45 -29
  89. package/src/media-text/media-container.js +3 -2
  90. package/src/navigation/edit/overlay-menu-icon.js +1 -5
  91. package/src/navigation/edit/overlay-menu-preview.js +0 -10
  92. package/src/navigation/index.php +0 -4
  93. package/src/navigation-link/edit.js +6 -2
  94. package/src/navigation-submenu/edit.js +6 -2
  95. package/src/post-comments-form/index.php +1 -1
  96. package/src/post-date/edit.js +13 -4
  97. package/src/post-featured-image/index.php +1 -1
  98. package/src/query/edit/index.js +50 -227
  99. package/src/query/edit/query-content.js +131 -0
  100. package/src/query/edit/query-placeholder.js +87 -8
  101. package/src/query/utils.js +46 -0
  102. package/src/search/index.php +1 -1
  103. package/src/social-link/edit.js +9 -9
  104. package/src/template-part/edit/selection-modal.js +2 -14
@@ -1,6 +1,6 @@
1
1
  // Jest Snapshot v1, https://goo.gl/fbAQLP
2
2
 
3
- exports[`List V2 block adds one item to the list 1`] = `
3
+ exports[`List block adds one item to the list 1`] = `
4
4
  "<!-- wp:list -->
5
5
  <ul><!-- wp:list-item -->
6
6
  <li>First list item</li>
@@ -8,7 +8,7 @@ exports[`List V2 block adds one item to the list 1`] = `
8
8
  <!-- /wp:list -->"
9
9
  `;
10
10
 
11
- exports[`List V2 block changes the indentation level 1`] = `
11
+ exports[`List block changes the indentation level 1`] = `
12
12
  "<!-- wp:list -->
13
13
  <ul><!-- wp:list-item -->
14
14
  <li>Item 1<!-- wp:list -->
@@ -20,7 +20,7 @@ exports[`List V2 block changes the indentation level 1`] = `
20
20
  <!-- /wp:list -->"
21
21
  `;
22
22
 
23
- exports[`List V2 block changes to ordered list 1`] = `
23
+ exports[`List block changes to ordered list 1`] = `
24
24
  "<!-- wp:list {\\"ordered\\":true} -->
25
25
  <ol><!-- wp:list-item -->
26
26
  <li>Item 1</li>
@@ -36,7 +36,7 @@ exports[`List V2 block changes to ordered list 1`] = `
36
36
  <!-- /wp:list -->"
37
37
  `;
38
38
 
39
- exports[`List V2 block changes to reverse ordered list 1`] = `
39
+ exports[`List block changes to reverse ordered list 1`] = `
40
40
  "<!-- wp:list {\\"ordered\\":true,\\"reversed\\":true} -->
41
41
  <ol reversed><!-- wp:list-item -->
42
42
  <li>Item 1</li>
@@ -52,7 +52,7 @@ exports[`List V2 block changes to reverse ordered list 1`] = `
52
52
  <!-- /wp:list -->"
53
53
  `;
54
54
 
55
- exports[`List V2 block inserts block 1`] = `
55
+ exports[`List block inserts block 1`] = `
56
56
  "<!-- wp:list -->
57
57
  <ul><!-- wp:list-item -->
58
58
  <li></li>
@@ -60,7 +60,7 @@ exports[`List V2 block inserts block 1`] = `
60
60
  <!-- /wp:list -->"
61
61
  `;
62
62
 
63
- exports[`List V2 block removes the indentation level 1`] = `
63
+ exports[`List block removes the indentation level 1`] = `
64
64
  "<!-- wp:list -->
65
65
  <ul><!-- wp:list-item -->
66
66
  <li>Item 1</li>
@@ -72,7 +72,7 @@ exports[`List V2 block removes the indentation level 1`] = `
72
72
  <!-- /wp:list -->"
73
73
  `;
74
74
 
75
- exports[`List V2 block sets a start value to an ordered list 1`] = `
75
+ exports[`List block sets a start value to an ordered list 1`] = `
76
76
  "<!-- wp:list {\\"ordered\\":true,\\"start\\":25} -->
77
77
  <ol start=\\"25\\"><!-- wp:list-item -->
78
78
  <li>Item 1</li>
@@ -88,7 +88,7 @@ exports[`List V2 block sets a start value to an ordered list 1`] = `
88
88
  <!-- /wp:list -->"
89
89
  `;
90
90
 
91
- exports[`List V2 block shows different indentation levels 1`] = `
91
+ exports[`List block shows different indentation levels 1`] = `
92
92
  "<!-- wp:list -->
93
93
  <ul><!-- wp:list-item -->
94
94
  <li>List item 1</li>
@@ -119,27 +119,3 @@ exports[`List V2 block shows different indentation levels 1`] = `
119
119
  <!-- /wp:list-item --></ul>
120
120
  <!-- /wp:list -->"
121
121
  `;
122
-
123
- exports[`List block inserts block 1`] = `
124
- "<!-- wp:list -->
125
- <ul><!-- wp:list-item -->
126
- <li></li>
127
- <!-- /wp:list-item --></ul>
128
- <!-- /wp:list -->"
129
- `;
130
-
131
- exports[`List block renders a list with a few items 1`] = `
132
- "<!-- wp:list -->
133
- <ul><!-- wp:list-item -->
134
- <li>Item 1</li>
135
- <!-- /wp:list-item -->
136
-
137
- <!-- wp:list-item -->
138
- <li>Item 2</li>
139
- <!-- /wp:list-item -->
140
-
141
- <!-- wp:list-item -->
142
- <li>Item 3</li>
143
- <!-- /wp:list-item --></ul>
144
- <!-- /wp:list -->"
145
- `;
@@ -8,6 +8,9 @@ import {
8
8
  initializeEditor,
9
9
  waitFor,
10
10
  within,
11
+ addBlock,
12
+ getBlock,
13
+ triggerBlockListLayout,
11
14
  } from 'test/helpers';
12
15
 
13
16
  /**
@@ -19,9 +22,7 @@ import { registerCoreBlocks } from '@wordpress/block-library';
19
22
  describe( 'List block', () => {
20
23
  beforeAll( () => {
21
24
  // Register all core blocks
22
- registerCoreBlocks( {
23
- __experimentalEnableListBlockV2: false,
24
- } );
25
+ registerCoreBlocks();
25
26
  } );
26
27
 
27
28
  afterAll( () => {
@@ -32,78 +33,25 @@ describe( 'List block', () => {
32
33
  } );
33
34
 
34
35
  it( 'inserts block', async () => {
35
- const { getByA11yLabel, getByTestId, getByText } =
36
- await initializeEditor();
37
-
38
- fireEvent.press( getByA11yLabel( 'Add block' ) );
39
-
40
- const blockList = getByTestId( 'InserterUI-Blocks' );
41
- // onScroll event used to force the FlatList to render all items
42
- fireEvent.scroll( blockList, {
43
- nativeEvent: {
44
- contentOffset: { y: 0, x: 0 },
45
- contentSize: { width: 100, height: 100 },
46
- layoutMeasurement: { width: 100, height: 100 },
47
- },
48
- } );
49
-
50
- fireEvent.press( await waitFor( () => getByText( 'List' ) ) );
51
-
52
- expect( getByA11yLabel( /List Block\. Row 1/ ) ).toBeVisible();
53
- expect( getEditorHtml() ).toMatchSnapshot();
54
- } );
55
-
56
- it( 'renders a list with a few items', async () => {
57
- const initialHtml = `<!-- wp:list -->
58
- <ul><li>Item 1</li><li>Item 2</li><li>Item 3</li></ul>
59
- <!-- /wp:list -->`;
36
+ const screen = await initializeEditor();
60
37
 
61
- const { getByA11yLabel } = await initializeEditor( {
62
- initialHtml,
63
- } );
38
+ // Add block
39
+ await addBlock( screen, 'List' );
64
40
 
65
- // Select List block
66
- const listBlock = getByA11yLabel( /List Block\. Row 1/ );
41
+ // Get block
42
+ const listBlock = await getBlock( screen, 'List' );
67
43
  fireEvent.press( listBlock );
44
+ expect( listBlock ).toBeVisible();
68
45
 
69
- expect( getEditorHtml() ).toMatchSnapshot();
70
- } );
71
- } );
72
-
73
- describe( 'List V2 block', () => {
74
- beforeAll( () => {
75
- // Register all core blocks
76
- registerCoreBlocks( {
77
- __experimentalEnableListBlockV2: true,
78
- } );
79
- } );
80
-
81
- afterAll( () => {
82
- // Clean up registered blocks
83
- getBlockTypes().forEach( ( block ) => {
84
- unregisterBlockType( block.name );
85
- } );
86
- } );
46
+ // Trigger onLayout for the list
47
+ await triggerBlockListLayout( listBlock );
87
48
 
88
- it( 'inserts block', async () => {
89
- const { getByA11yLabel, getByTestId, getByText } =
90
- await initializeEditor();
91
-
92
- fireEvent.press( getByA11yLabel( 'Add block' ) );
93
-
94
- const blockList = getByTestId( 'InserterUI-Blocks' );
95
- // onScroll event used to force the FlatList to render all items
96
- fireEvent.scroll( blockList, {
97
- nativeEvent: {
98
- contentOffset: { y: 0, x: 0 },
99
- contentSize: { width: 100, height: 100 },
100
- layoutMeasurement: { width: 100, height: 100 },
101
- },
102
- } );
49
+ // Get List item
50
+ const listItemBlock = await getBlock( screen, 'List item' );
51
+ fireEvent.press( listItemBlock );
103
52
 
104
- fireEvent.press( await waitFor( () => getByText( 'List' ) ) );
53
+ expect( listItemBlock ).toBeVisible();
105
54
 
106
- expect( getByA11yLabel( /List Block\. Row 1/ ) ).toBeVisible();
107
55
  expect( getEditorHtml() ).toMatchSnapshot();
108
56
  } );
109
57
 
@@ -137,7 +137,7 @@ function attributesFromMedia( {
137
137
  };
138
138
  }
139
139
 
140
- function MediaTextEdit( { attributes, isSelected, setAttributes } ) {
140
+ function MediaTextEdit( { attributes, isSelected, setAttributes, clientId } ) {
141
141
  const {
142
142
  focalPoint,
143
143
  href,
@@ -157,12 +157,24 @@ function MediaTextEdit( { attributes, isSelected, setAttributes } ) {
157
157
  } = attributes;
158
158
  const mediaSizeSlug = attributes.mediaSizeSlug || DEFAULT_MEDIA_SIZE_SLUG;
159
159
 
160
- const image = useSelect(
161
- ( select ) =>
162
- mediaId && isSelected
163
- ? select( coreStore ).getMedia( mediaId, { context: 'view' } )
164
- : null,
165
- [ isSelected, mediaId ]
160
+ const { imageSizes, image, isContentLocked } = useSelect(
161
+ ( select ) => {
162
+ const { __unstableGetContentLockingParent, getSettings } =
163
+ select( blockEditorStore );
164
+ return {
165
+ isContentLocked:
166
+ !! __unstableGetContentLockingParent( clientId ),
167
+ image:
168
+ mediaId && isSelected
169
+ ? select( coreStore ).getMedia( mediaId, {
170
+ context: 'view',
171
+ } )
172
+ : null,
173
+ imageSizes: getSettings()?.imageSizes,
174
+ };
175
+ },
176
+
177
+ [ isSelected, mediaId, clientId ]
166
178
  );
167
179
 
168
180
  const refMediaContainer = useRef();
@@ -213,10 +225,6 @@ function MediaTextEdit( { attributes, isSelected, setAttributes } ) {
213
225
  setAttributes( { verticalAlignment: alignment } );
214
226
  };
215
227
 
216
- const imageSizes = useSelect( ( select ) => {
217
- const settings = select( blockEditorStore ).getSettings();
218
- return settings?.imageSizes;
219
- }, [] );
220
228
  const imageSizeOptions = map(
221
229
  filter( imageSizes, ( { slug } ) =>
222
230
  getImageSourceUrlBySizeSlug( image, slug )
@@ -322,24 +330,31 @@ function MediaTextEdit( { attributes, isSelected, setAttributes } ) {
322
330
  <>
323
331
  <InspectorControls>{ mediaTextGeneralSettings }</InspectorControls>
324
332
  <BlockControls group="block">
325
- <BlockVerticalAlignmentControl
326
- onChange={ onVerticalAlignmentChange }
327
- value={ verticalAlignment }
328
- />
329
- <ToolbarButton
330
- icon={ pullLeft }
331
- title={ __( 'Show media on left' ) }
332
- isActive={ mediaPosition === 'left' }
333
- onClick={ () => setAttributes( { mediaPosition: 'left' } ) }
334
- />
335
- <ToolbarButton
336
- icon={ pullRight }
337
- title={ __( 'Show media on right' ) }
338
- isActive={ mediaPosition === 'right' }
339
- onClick={ () =>
340
- setAttributes( { mediaPosition: 'right' } )
341
- }
342
- />
333
+ { ! isContentLocked && (
334
+ <>
335
+ <BlockVerticalAlignmentControl
336
+ onChange={ onVerticalAlignmentChange }
337
+ value={ verticalAlignment }
338
+ />
339
+ <ToolbarButton
340
+ icon={ pullLeft }
341
+ title={ __( 'Show media on left' ) }
342
+ isActive={ mediaPosition === 'left' }
343
+ onClick={ () =>
344
+ setAttributes( { mediaPosition: 'left' } )
345
+ }
346
+ />
347
+ <ToolbarButton
348
+ icon={ pullRight }
349
+ title={ __( 'Show media on right' ) }
350
+ isActive={ mediaPosition === 'right' }
351
+ onClick={ () =>
352
+ setAttributes( { mediaPosition: 'right' } )
353
+ }
354
+ />
355
+ </>
356
+ ) }
357
+
343
358
  { mediaType === 'image' && (
344
359
  <ImageURLInputUI
345
360
  url={ href || '' }
@@ -373,6 +388,7 @@ function MediaTextEdit( { attributes, isSelected, setAttributes } ) {
373
388
  mediaType,
374
389
  mediaUrl,
375
390
  mediaWidth,
391
+ isContentLocked,
376
392
  } }
377
393
  />
378
394
  { mediaPosition !== 'right' && <div { ...innerBlocksProps } /> }
@@ -113,6 +113,7 @@ function MediaContainer( props, ref ) {
113
113
  mediaWidth,
114
114
  onSelectMedia,
115
115
  onWidthChange,
116
+ isContentLocked,
116
117
  } = props;
117
118
 
118
119
  const isTemporaryMedia = ! mediaId && isBlobURL( mediaUrl );
@@ -131,8 +132,8 @@ function MediaContainer( props, ref ) {
131
132
  commitWidthChange( parseInt( elt.style.width ) );
132
133
  };
133
134
  const enablePositions = {
134
- right: mediaPosition === 'left',
135
- left: mediaPosition === 'right',
135
+ right: ! isContentLocked && mediaPosition === 'left',
136
+ left: ! isContentLocked && mediaPosition === 'right',
136
137
  };
137
138
 
138
139
  const backgroundStyles =
@@ -2,15 +2,11 @@
2
2
  * WordPress dependencies
3
3
  */
4
4
  import { SVG, Rect } from '@wordpress/primitives';
5
- import { Icon, menu, moreVertical, moreHorizontal } from '@wordpress/icons';
5
+ import { Icon, menu } from '@wordpress/icons';
6
6
 
7
7
  export default function OverlayMenuIcon( { icon } ) {
8
8
  if ( icon === 'menu' ) {
9
9
  return <Icon icon={ menu } />;
10
- } else if ( icon === 'more-vertical' ) {
11
- return <Icon icon={ moreVertical } />;
12
- } else if ( icon === 'more-horizontal' ) {
13
- return <Icon icon={ moreHorizontal } />;
14
10
  }
15
11
 
16
12
  return (
@@ -41,16 +41,6 @@ export default function OverlayMenuPreview( { setAttributes, hasIcon, icon } ) {
41
41
  aria-label={ __( 'menu' ) }
42
42
  label={ <OverlayMenuIcon icon="menu" /> }
43
43
  />
44
- <ToggleGroupControlOption
45
- value="more-vertical"
46
- aria-label={ __( 'more vertical' ) }
47
- label={ <OverlayMenuIcon icon="more-vertical" /> }
48
- />
49
- <ToggleGroupControlOption
50
- value="more-horizontal"
51
- aria-label={ __( 'more horizontal' ) }
52
- label={ <OverlayMenuIcon icon="more-horizontal" /> }
53
- />
54
44
  </ToggleGroupControl>
55
45
  </>
56
46
  );
@@ -623,10 +623,6 @@ function render_block_core_navigation( $attributes, $content, $block ) {
623
623
  if ( isset( $attributes['icon'] ) ) {
624
624
  if ( 'menu' === $attributes['icon'] ) {
625
625
  $toggle_button_icon = '<svg width="24" height="24" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M5 5v1.5h14V5H5zm0 7.8h14v-1.5H5v1.5zM5 19h14v-1.5H5V19z" /></svg>';
626
- } elseif ( 'more-vertical' === $attributes['icon'] ) {
627
- $toggle_button_icon = '<svg width="24" height="24" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M13 19h-2v-2h2v2zm0-6h-2v-2h2v2zm0-6h-2V5h2v2z" /></svg>';
628
- } elseif ( 'more-horizontal' === $attributes['icon'] ) {
629
- $toggle_button_icon = '<svg width="24" height="24" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M11 13h2v-2h-2v2zm-6 0h2v-2H5v2zm12-2v2h2v-2h-2z" /></svg>';
630
626
  }
631
627
  }
632
628
  $toggle_button_content = $should_display_icon_label ? $toggle_button_icon : __( 'Menu' );
@@ -47,6 +47,7 @@ import {
47
47
  useResourcePermissions,
48
48
  } from '@wordpress/core-data';
49
49
  import { decodeEntities } from '@wordpress/html-entities';
50
+ import { useMergeRefs } from '@wordpress/compose';
50
51
 
51
52
  /**
52
53
  * Internal dependencies
@@ -461,6 +462,9 @@ export default function NavigationLinkEdit( {
461
462
  const { replaceBlock, __unstableMarkNextChangeAsNotPersistent } =
462
463
  useDispatch( blockEditorStore );
463
464
  const [ isLinkOpen, setIsLinkOpen ] = useState( false );
465
+ // Use internal state instead of a ref to make sure that the component
466
+ // re-renders when the popover's anchor updates.
467
+ const [ popoverAnchor, setPopoverAnchor ] = useState( null );
464
468
  const listItemRef = useRef( null );
465
469
  const isDraggingWithin = useIsDraggingWithin( listItemRef );
466
470
  const itemLabelPlaceholder = __( 'Add link…' );
@@ -651,7 +655,7 @@ export default function NavigationLinkEdit( {
651
655
  }
652
656
 
653
657
  const blockProps = useBlockProps( {
654
- ref: listItemRef,
658
+ ref: useMergeRefs( [ setPopoverAnchor, listItemRef ] ),
655
659
  className: classnames( 'wp-block-navigation-item', {
656
660
  'is-editing': isSelected || isParentOfSelectedBlock,
657
661
  'is-dragging-within': isDraggingWithin,
@@ -844,7 +848,7 @@ export default function NavigationLinkEdit( {
844
848
  <Popover
845
849
  position="bottom center"
846
850
  onClose={ () => setIsLinkOpen( false ) }
847
- anchorRef={ listItemRef.current }
851
+ anchor={ popoverAnchor }
848
852
  shift
849
853
  >
850
854
  <LinkControl
@@ -45,6 +45,7 @@ import {
45
45
  } from '@wordpress/core-data';
46
46
  import { speak } from '@wordpress/a11y';
47
47
  import { createBlock } from '@wordpress/blocks';
48
+ import { useMergeRefs } from '@wordpress/compose';
48
49
 
49
50
  /**
50
51
  * Internal dependencies
@@ -292,6 +293,9 @@ export default function NavigationSubmenuEdit( {
292
293
  const { __unstableMarkNextChangeAsNotPersistent, replaceBlock } =
293
294
  useDispatch( blockEditorStore );
294
295
  const [ isLinkOpen, setIsLinkOpen ] = useState( false );
296
+ // Use internal state instead of a ref to make sure that the component
297
+ // re-renders when the popover's anchor updates.
298
+ const [ popoverAnchor, setPopoverAnchor ] = useState( null );
295
299
  const listItemRef = useRef( null );
296
300
  const isDraggingWithin = useIsDraggingWithin( listItemRef );
297
301
  const itemLabelPlaceholder = __( 'Add text…' );
@@ -458,7 +462,7 @@ export default function NavigationSubmenuEdit( {
458
462
  }
459
463
 
460
464
  const blockProps = useBlockProps( {
461
- ref: listItemRef,
465
+ ref: useMergeRefs( [ setPopoverAnchor, listItemRef ] ),
462
466
  className: classnames( 'wp-block-navigation-item', {
463
467
  'is-editing': isSelected || isParentOfSelectedBlock,
464
468
  'is-dragging-within': isDraggingWithin,
@@ -629,7 +633,7 @@ export default function NavigationSubmenuEdit( {
629
633
  <Popover
630
634
  position="bottom center"
631
635
  onClose={ () => setIsLinkOpen( false ) }
632
- anchorRef={ listItemRef.current }
636
+ anchor={ popoverAnchor }
633
637
  shift
634
638
  >
635
639
  <LinkControl
@@ -72,7 +72,7 @@ add_action( 'init', 'register_block_core_post_comments_form' );
72
72
  */
73
73
  function post_comments_form_block_form_defaults( $fields ) {
74
74
  if ( wp_is_block_theme() ) {
75
- $fields['submit_button'] = '<input name="%1$s" type="submit" id="%2$s" class="wp-block-button__link ' . wp_theme_element_class_name( 'button' ) . '" value="%4$s" />';
75
+ $fields['submit_button'] = '<input name="%1$s" type="submit" id="%2$s" class="wp-block-button__link ' . wp_theme_get_element_class_name( 'button' ) . '" value="%4$s" />';
76
76
  $fields['submit_field'] = '<p class="form-submit wp-block-button">%1$s %2$s</p>';
77
77
  }
78
78
 
@@ -7,7 +7,7 @@ import classnames from 'classnames';
7
7
  * WordPress dependencies
8
8
  */
9
9
  import { useEntityProp, store as coreStore } from '@wordpress/core-data';
10
- import { useRef } from '@wordpress/element';
10
+ import { useMemo, useState } from '@wordpress/element';
11
11
  import { dateI18n, getSettings as getDateSettings } from '@wordpress/date';
12
12
  import {
13
13
  AlignmentControl,
@@ -39,7 +39,16 @@ export default function PostDateEdit( {
39
39
  [ `has-text-align-${ textAlign }` ]: textAlign,
40
40
  } ),
41
41
  } );
42
- const timeRef = useRef();
42
+
43
+ // Use internal state instead of a ref to make sure that the component
44
+ // re-renders when the popover's anchor updates.
45
+ const [ popoverAnchor, setPopoverAnchor ] = useState( null );
46
+ // Memoize popoverProps to avoid returning a new object every time.
47
+ const popoverProps = useMemo(
48
+ () => ( { anchor: popoverAnchor } ),
49
+ [ popoverAnchor ]
50
+ );
51
+
43
52
  const isDescendentOfQueryLoop = Number.isFinite( queryId );
44
53
  const dateSettings = getDateSettings();
45
54
  const [ siteFormat = dateSettings.formats.date ] = useEntityProp(
@@ -68,7 +77,7 @@ export default function PostDateEdit( {
68
77
  );
69
78
 
70
79
  let postDate = date ? (
71
- <time dateTime={ dateI18n( 'c', date ) } ref={ timeRef }>
80
+ <time dateTime={ dateI18n( 'c', date ) } ref={ setPopoverAnchor }>
72
81
  { dateI18n( format || siteFormat, date ) }
73
82
  </time>
74
83
  ) : (
@@ -98,7 +107,7 @@ export default function PostDateEdit( {
98
107
  { date && ! isDescendentOfQueryLoop && (
99
108
  <ToolbarGroup>
100
109
  <Dropdown
101
- popoverProps={ { anchorRef: timeRef.current } }
110
+ popoverProps={ popoverProps }
102
111
  renderContent={ ( { onClose } ) => (
103
112
  <PublishDateTimePicker
104
113
  currentDate={ date }
@@ -182,7 +182,7 @@ function get_block_core_post_featured_image_border_attributes( $attributes ) {
182
182
  );
183
183
  }
184
184
 
185
- $styles = gutenberg_style_engine_get_styles( array( 'border' => $border_styles ) );
185
+ $styles = wp_style_engine_get_styles( array( 'border' => $border_styles ) );
186
186
  $attributes = array();
187
187
  if ( ! empty( $styles['classnames'] ) ) {
188
188
  $attributes['class'] = $styles['classnames'];