@wordpress/block-editor 14.14.0 → 14.14.2

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 (23) hide show
  1. package/build/components/block-popover/use-popover-scroll.js +2 -1
  2. package/build/components/block-popover/use-popover-scroll.js.map +1 -1
  3. package/build/components/inserter/block-patterns-explorer/pattern-list.js +3 -0
  4. package/build/components/inserter/block-patterns-explorer/pattern-list.js.map +1 -1
  5. package/build/components/link-control/search-input.js +2 -3
  6. package/build/components/link-control/search-input.js.map +1 -1
  7. package/build/components/writing-flow/use-tab-nav.js +21 -14
  8. package/build/components/writing-flow/use-tab-nav.js.map +1 -1
  9. package/build-module/components/block-popover/use-popover-scroll.js +2 -1
  10. package/build-module/components/block-popover/use-popover-scroll.js.map +1 -1
  11. package/build-module/components/inserter/block-patterns-explorer/pattern-list.js +4 -1
  12. package/build-module/components/inserter/block-patterns-explorer/pattern-list.js.map +1 -1
  13. package/build-module/components/link-control/search-input.js +2 -3
  14. package/build-module/components/link-control/search-input.js.map +1 -1
  15. package/build-module/components/writing-flow/use-tab-nav.js +21 -14
  16. package/build-module/components/writing-flow/use-tab-nav.js.map +1 -1
  17. package/package.json +34 -34
  18. package/src/components/block-popover/use-popover-scroll.js +2 -1
  19. package/src/components/inserter/block-patterns-explorer/pattern-list.js +7 -0
  20. package/src/components/link-control/search-input.js +2 -4
  21. package/src/components/link-control/test/index.js +46 -46
  22. package/src/components/media-replace-flow/test/index.js +1 -1
  23. package/src/components/writing-flow/use-tab-nav.js +22 -17
@@ -139,7 +139,7 @@ describe( 'Basic rendering', () => {
139
139
 
140
140
  // Search Input UI.
141
141
  const searchInput = screen.getByRole( 'combobox', {
142
- name: 'Search or type URL',
142
+ name: 'Link',
143
143
  } );
144
144
 
145
145
  expect( searchInput ).toBeVisible();
@@ -150,7 +150,7 @@ describe( 'Basic rendering', () => {
150
150
 
151
151
  // Search Input UI.
152
152
  const searchInput = screen.getByRole( 'combobox', {
153
- name: 'Search or type URL',
153
+ name: 'Link',
154
154
  } );
155
155
 
156
156
  expect( searchInput ).toBeVisible();
@@ -175,7 +175,7 @@ describe( 'Basic rendering', () => {
175
175
 
176
176
  // Search Input UI.
177
177
  const searchInput = screen.getByRole( 'combobox', {
178
- name: 'Search or type URL',
178
+ name: 'Link',
179
179
  } );
180
180
 
181
181
  // Simulate searching for a term.
@@ -290,7 +290,7 @@ describe( 'Basic rendering', () => {
290
290
 
291
291
  // Search Input UI.
292
292
  const searchInput = screen.getByRole( 'combobox', {
293
- name: 'Search or type URL',
293
+ name: 'Link',
294
294
  } );
295
295
 
296
296
  // Simulate searching for a term.
@@ -304,7 +304,7 @@ describe( 'Basic rendering', () => {
304
304
  render( <LinkControl value={ { url: 'https://example.com' } } /> );
305
305
 
306
306
  expect(
307
- screen.queryByRole( 'combobox', { name: 'Search or type URL' } )
307
+ screen.queryByRole( 'combobox', { name: 'Link' } )
308
308
  ).not.toBeInTheDocument();
309
309
  } );
310
310
 
@@ -317,7 +317,7 @@ describe( 'Basic rendering', () => {
317
317
  );
318
318
 
319
319
  expect(
320
- screen.getByRole( 'combobox', { name: 'Search or type URL' } )
320
+ screen.getByRole( 'combobox', { name: 'Link' } )
321
321
  ).toBeVisible();
322
322
  } );
323
323
 
@@ -335,7 +335,7 @@ describe( 'Basic rendering', () => {
335
335
  await user.click( editButton );
336
336
 
337
337
  expect(
338
- screen.getByRole( 'combobox', { name: 'Search or type URL' } )
338
+ screen.getByRole( 'combobox', { name: 'Link' } )
339
339
  ).toBeVisible();
340
340
 
341
341
  // If passed `forceIsEditingLink` of `false` while editing, should
@@ -348,7 +348,7 @@ describe( 'Basic rendering', () => {
348
348
  );
349
349
 
350
350
  expect(
351
- screen.queryByRole( 'combobox', { name: 'Search or type URL' } )
351
+ screen.queryByRole( 'combobox', { name: 'Link' } )
352
352
  ).not.toBeInTheDocument();
353
353
  } );
354
354
 
@@ -438,7 +438,7 @@ describe( 'Basic rendering', () => {
438
438
 
439
439
  // Should revert back to editing mode.
440
440
  expect(
441
- screen.getByRole( 'combobox', { name: 'Search or type URL' } )
441
+ screen.getByRole( 'combobox', { name: 'Link' } )
442
442
  ).toBeVisible();
443
443
  } );
444
444
  } );
@@ -461,7 +461,7 @@ describe( 'Searching for a link', () => {
461
461
 
462
462
  // Search Input UI.
463
463
  const searchInput = screen.getByRole( 'combobox', {
464
- name: 'Search or type URL',
464
+ name: 'Link',
465
465
  } );
466
466
 
467
467
  // Simulate searching for a term.
@@ -487,7 +487,7 @@ describe( 'Searching for a link', () => {
487
487
 
488
488
  // Search Input UI.
489
489
  const searchInput = screen.getByRole( 'combobox', {
490
- name: 'Search or type URL',
490
+ name: 'Link',
491
491
  } );
492
492
 
493
493
  // Simulate searching for a term.
@@ -538,7 +538,7 @@ describe( 'Searching for a link', () => {
538
538
 
539
539
  // Search Input UI.
540
540
  const searchInput = screen.getByRole( 'combobox', {
541
- name: 'Search or type URL',
541
+ name: 'Link',
542
542
  } );
543
543
 
544
544
  // Simulate searching for a term.
@@ -571,7 +571,7 @@ describe( 'Searching for a link', () => {
571
571
 
572
572
  // Search Input UI.
573
573
  const searchInput = screen.getByRole( 'combobox', {
574
- name: 'Search or type URL',
574
+ name: 'Link',
575
575
  } );
576
576
 
577
577
  // Simulate searching for a term.
@@ -616,7 +616,7 @@ describe( 'Searching for a link', () => {
616
616
 
617
617
  // Search Input UI.
618
618
  const searchInput = screen.getByRole( 'combobox', {
619
- name: 'Search or type URL',
619
+ name: 'Link',
620
620
  } );
621
621
 
622
622
  // Simulate searching for a term.
@@ -635,7 +635,7 @@ describe( 'Searching for a link', () => {
635
635
 
636
636
  // Search Input UI.
637
637
  const searchInput = screen.getByRole( 'combobox', {
638
- name: 'Search or type URL',
638
+ name: 'Link',
639
639
  } );
640
640
 
641
641
  // Simulate searching for a term.
@@ -667,7 +667,7 @@ describe( 'Searching for a link', () => {
667
667
 
668
668
  // Search Input UI.
669
669
  const searchInput = screen.getByRole( 'combobox', {
670
- name: 'Search or type URL',
670
+ name: 'Link',
671
671
  } );
672
672
 
673
673
  // Simulate searching for a term.
@@ -699,7 +699,7 @@ describe( 'Manual link entry', () => {
699
699
 
700
700
  // Search Input UI.
701
701
  const searchInput = screen.getByRole( 'combobox', {
702
- name: 'Search or type URL',
702
+ name: 'Link',
703
703
  } );
704
704
 
705
705
  // Simulate searching for a term.
@@ -735,7 +735,7 @@ describe( 'Manual link entry', () => {
735
735
 
736
736
  // Search Input UI.
737
737
  const searchInput = screen.getByRole( 'combobox', {
738
- name: 'Search or type URL',
738
+ name: 'Link',
739
739
  } );
740
740
 
741
741
  if ( searchString.length ) {
@@ -769,7 +769,7 @@ describe( 'Manual link entry', () => {
769
769
 
770
770
  // Search Input UI.
771
771
  const searchInput = screen.getByRole( 'combobox', {
772
- name: 'Search or type URL',
772
+ name: 'Link',
773
773
  } );
774
774
 
775
775
  // Remove the existing link.
@@ -852,7 +852,7 @@ describe( 'Manual link entry', () => {
852
852
  await toggleSettingsDrawer( user );
853
853
 
854
854
  let searchInput = screen.getByRole( 'combobox', {
855
- name: 'Search or type URL',
855
+ name: 'Link',
856
856
  } );
857
857
 
858
858
  let textInput = screen.getByRole( 'textbox', {
@@ -889,7 +889,7 @@ describe( 'Manual link entry', () => {
889
889
 
890
890
  // Re-query the inputs as they have been replaced.
891
891
  searchInput = screen.getByRole( 'combobox', {
892
- name: 'Search or type URL',
892
+ name: 'Link',
893
893
  } );
894
894
 
895
895
  textInput = screen.getByRole( 'textbox', {
@@ -937,7 +937,7 @@ describe( 'Manual link entry', () => {
937
937
 
938
938
  // Search Input UI.
939
939
  const searchInput = screen.getByRole( 'combobox', {
940
- name: 'Search or type URL',
940
+ name: 'Link',
941
941
  } );
942
942
 
943
943
  // Simulate searching for a term.
@@ -973,7 +973,7 @@ describe( 'Link submission', () => {
973
973
  render( <LinkControlConsumer /> );
974
974
 
975
975
  const searchInput = screen.getByRole( 'combobox', {
976
- name: 'Search or type URL',
976
+ name: 'Link',
977
977
  } );
978
978
 
979
979
  const submitButton = screen.getByRole( 'button', {
@@ -1012,7 +1012,7 @@ describe( 'Link submission', () => {
1012
1012
  render( <LinkControlConsumer /> );
1013
1013
 
1014
1014
  const searchInput = screen.getByRole( 'combobox', {
1015
- name: 'Search or type URL',
1015
+ name: 'Link',
1016
1016
  } );
1017
1017
 
1018
1018
  const createSubmitButton = screen.queryByRole( 'button', {
@@ -1059,9 +1059,9 @@ describe( 'Default search suggestions', () => {
1059
1059
  // Verify input has no value has default suggestions should only show
1060
1060
  // when this does not have a value.
1061
1061
  // Search Input UI.
1062
- expect(
1063
- screen.getByRole( 'combobox', { name: 'Search or type URL' } )
1064
- ).toHaveValue( '' );
1062
+ expect( screen.getByRole( 'combobox', { name: 'Link' } ) ).toHaveValue(
1063
+ ''
1064
+ );
1065
1065
 
1066
1066
  // Ensure only called once as a guard against potential infinite
1067
1067
  // re-render loop within `componentDidUpdate` calling `updateSuggestions`
@@ -1091,7 +1091,7 @@ describe( 'Default search suggestions', () => {
1091
1091
  await user.click( currentLinkBtn );
1092
1092
 
1093
1093
  const searchInput = screen.getByRole( 'combobox', {
1094
- name: 'Search or type URL',
1094
+ name: 'Link',
1095
1095
  } );
1096
1096
 
1097
1097
  // Search input is set to the URL value.
@@ -1115,7 +1115,7 @@ describe( 'Default search suggestions', () => {
1115
1115
 
1116
1116
  // Search Input UI.
1117
1117
  const searchInput = screen.getByRole( 'combobox', {
1118
- name: 'Search or type URL',
1118
+ name: 'Link',
1119
1119
  } );
1120
1120
 
1121
1121
  // Simulate searching for a term.
@@ -1155,7 +1155,7 @@ describe( 'Default search suggestions', () => {
1155
1155
  render( <LinkControl showInitialSuggestions /> );
1156
1156
 
1157
1157
  const searchInput = screen.getByRole( 'combobox', {
1158
- name: 'Search or type URL',
1158
+ name: 'Link',
1159
1159
  } );
1160
1160
 
1161
1161
  const searchResultsField = screen.queryByRole( 'listbox', {
@@ -1215,7 +1215,7 @@ describe( 'Creating Entities (eg: Posts, Pages)', () => {
1215
1215
 
1216
1216
  // Search Input UI.
1217
1217
  const searchInput = screen.getByRole( 'combobox', {
1218
- name: 'Search or type URL',
1218
+ name: 'Link',
1219
1219
  } );
1220
1220
 
1221
1221
  // Simulate searching for a term.
@@ -1285,7 +1285,7 @@ describe( 'Creating Entities (eg: Posts, Pages)', () => {
1285
1285
 
1286
1286
  // Search Input UI.
1287
1287
  const searchInput = screen.getByRole( 'combobox', {
1288
- name: 'Search or type URL',
1288
+ name: 'Link',
1289
1289
  } );
1290
1290
 
1291
1291
  // Simulate searching for a term.
@@ -1338,7 +1338,7 @@ describe( 'Creating Entities (eg: Posts, Pages)', () => {
1338
1338
 
1339
1339
  // Search Input UI.
1340
1340
  const searchInput = screen.getByRole( 'combobox', {
1341
- name: 'Search or type URL',
1341
+ name: 'Link',
1342
1342
  } );
1343
1343
 
1344
1344
  // Simulate searching for a term.
@@ -1385,7 +1385,7 @@ describe( 'Creating Entities (eg: Posts, Pages)', () => {
1385
1385
 
1386
1386
  // Search Input UI.
1387
1387
  const searchInput = screen.getByRole( 'combobox', {
1388
- name: 'Search or type URL',
1388
+ name: 'Link',
1389
1389
  } );
1390
1390
 
1391
1391
  // Simulate searching for a term.
@@ -1410,7 +1410,7 @@ describe( 'Creating Entities (eg: Posts, Pages)', () => {
1410
1410
 
1411
1411
  // Search Input UI.
1412
1412
  const searchInput = screen.getByRole( 'combobox', {
1413
- name: 'Search or type URL',
1413
+ name: 'Link',
1414
1414
  } );
1415
1415
 
1416
1416
  const searchResultsField = screen.queryByRole( 'listbox' );
@@ -1431,7 +1431,7 @@ describe( 'Creating Entities (eg: Posts, Pages)', () => {
1431
1431
 
1432
1432
  // Search Input UI.
1433
1433
  const searchInput = screen.getByRole( 'combobox', {
1434
- name: 'Search or type URL',
1434
+ name: 'Link',
1435
1435
  } );
1436
1436
 
1437
1437
  const searchResultsField = screen.queryByRole( 'listbox' );
@@ -1455,7 +1455,7 @@ describe( 'Creating Entities (eg: Posts, Pages)', () => {
1455
1455
 
1456
1456
  // Search Input UI.
1457
1457
  const searchInput = screen.getByRole( 'combobox', {
1458
- name: 'Search or type URL',
1458
+ name: 'Link',
1459
1459
  } );
1460
1460
 
1461
1461
  // Simulate searching for a term.
@@ -1490,7 +1490,7 @@ describe( 'Creating Entities (eg: Posts, Pages)', () => {
1490
1490
 
1491
1491
  // Search Input UI.
1492
1492
  searchInput = screen.getByRole( 'combobox', {
1493
- name: 'Search or type URL',
1493
+ name: 'Link',
1494
1494
  } );
1495
1495
 
1496
1496
  // Simulate searching for a term.
@@ -1507,7 +1507,7 @@ describe( 'Creating Entities (eg: Posts, Pages)', () => {
1507
1507
  await user.click( createButton );
1508
1508
 
1509
1509
  searchInput = screen.getByRole( 'combobox', {
1510
- name: 'Search or type URL',
1510
+ name: 'Link',
1511
1511
  } );
1512
1512
 
1513
1513
  const errorNotice = screen.getAllByText(
@@ -1586,7 +1586,7 @@ describe( 'Selecting links', () => {
1586
1586
  await user.click( currentLinkBtn );
1587
1587
 
1588
1588
  const searchInput = screen.getByRole( 'combobox', {
1589
- name: 'Search or type URL',
1589
+ name: 'Link',
1590
1590
  } );
1591
1591
  currentLinkUI = screen.queryByRole( 'group', {
1592
1592
  name: 'Manage link',
@@ -1630,7 +1630,7 @@ describe( 'Selecting links', () => {
1630
1630
 
1631
1631
  // Search Input UI.
1632
1632
  const searchInput = screen.getByRole( 'combobox', {
1633
- name: 'Search or type URL',
1633
+ name: 'Link',
1634
1634
  } );
1635
1635
 
1636
1636
  // Simulate searching for a term.
@@ -1692,7 +1692,7 @@ describe( 'Selecting links', () => {
1692
1692
 
1693
1693
  // Search Input UI.
1694
1694
  const searchInput = screen.getByRole( 'combobox', {
1695
- name: 'Search or type URL',
1695
+ name: 'Link',
1696
1696
  } );
1697
1697
 
1698
1698
  // Simulate searching for a term.
@@ -1783,7 +1783,7 @@ describe( 'Selecting links', () => {
1783
1783
 
1784
1784
  // Search Input UI.
1785
1785
  const searchInput = screen.getByRole( 'combobox', {
1786
- name: 'Search or type URL',
1786
+ name: 'Link',
1787
1787
  } );
1788
1788
 
1789
1789
  // Step down into the search results, highlighting the first result item.
@@ -1841,7 +1841,7 @@ describe( 'Selecting links', () => {
1841
1841
 
1842
1842
  // focus the search input
1843
1843
  const searchInput = screen.getByRole( 'combobox', {
1844
- name: 'Search or type URL',
1844
+ name: 'Link',
1845
1845
  } );
1846
1846
 
1847
1847
  fireEvent.focus( searchInput );
@@ -2064,7 +2064,7 @@ describe( 'Post types', () => {
2064
2064
 
2065
2065
  // Search Input UI.
2066
2066
  const searchInput = screen.getByRole( 'combobox', {
2067
- name: 'Search or type URL',
2067
+ name: 'Link',
2068
2068
  } );
2069
2069
 
2070
2070
  // Simulate searching for a term.
@@ -2093,7 +2093,7 @@ describe( 'Post types', () => {
2093
2093
 
2094
2094
  // Search Input UI.
2095
2095
  const searchInput = screen.getByRole( 'combobox', {
2096
- name: 'Search or type URL',
2096
+ name: 'Link',
2097
2097
  } );
2098
2098
 
2099
2099
  // Simulate searching for a term.
@@ -110,7 +110,7 @@ describe( 'General media replace flow', () => {
110
110
  );
111
111
 
112
112
  const mediaURLInput = screen.getByRole( 'combobox', {
113
- name: 'Search or type URL',
113
+ name: 'Link',
114
114
  expanded: false,
115
115
  } );
116
116
 
@@ -15,7 +15,7 @@ import { isInSameBlock, isInsideRootBlock } from '../../utils/dom';
15
15
  import { unlock } from '../../lock-unlock';
16
16
 
17
17
  export default function useTabNav() {
18
- const container = useRef();
18
+ const containerRef = /** @type {typeof useRef<HTMLElement>} */ ( useRef )();
19
19
  const focusCaptureBeforeRef = useRef();
20
20
  const focusCaptureAfterRef = useRef();
21
21
 
@@ -36,21 +36,21 @@ export default function useTabNav() {
36
36
 
37
37
  function onFocusCapture( event ) {
38
38
  const canvasElement =
39
- container.current.ownerDocument === event.target.ownerDocument
40
- ? container.current
41
- : container.current.ownerDocument.defaultView.frameElement;
39
+ containerRef.current.ownerDocument === event.target.ownerDocument
40
+ ? containerRef.current
41
+ : containerRef.current.ownerDocument.defaultView.frameElement;
42
42
 
43
43
  // Do not capture incoming focus if set by us in WritingFlow.
44
44
  if ( noCaptureRef.current ) {
45
45
  noCaptureRef.current = null;
46
46
  } else if ( hasMultiSelection() ) {
47
- container.current.focus();
47
+ containerRef.current.focus();
48
48
  } else if ( getSelectedBlockClientId() ) {
49
49
  if ( getLastFocus()?.current ) {
50
50
  getLastFocus().current.focus();
51
51
  } else {
52
52
  // Handles when the last focus has not been set yet, or has been cleared by new blocks being added via the inserter.
53
- container.current
53
+ containerRef.current
54
54
  .querySelector(
55
55
  `[data-block="${ getSelectedBlockClientId() }"]`
56
56
  )
@@ -64,13 +64,13 @@ export default function useTabNav() {
64
64
 
65
65
  // If we have section within the section root, focus the first one.
66
66
  if ( sectionBlocks.length ) {
67
- container.current
67
+ containerRef.current
68
68
  .querySelector( `[data-block="${ sectionBlocks[ 0 ] }"]` )
69
69
  .focus();
70
70
  }
71
71
  // If we don't have any section blocks, focus the section root.
72
72
  else if ( sectionRootClientId ) {
73
- container.current
73
+ containerRef.current
74
74
  .querySelector( `[data-block="${ sectionRootClientId }"]` )
75
75
  .focus();
76
76
  } else {
@@ -82,8 +82,7 @@ export default function useTabNav() {
82
82
  // eslint-disable-next-line no-bitwise
83
83
  event.target.compareDocumentPosition( canvasElement ) &
84
84
  event.target.DOCUMENT_POSITION_FOLLOWING;
85
- const tabbables = focus.tabbable.find( container.current );
86
-
85
+ const tabbables = focus.tabbable.find( containerRef.current );
87
86
  if ( tabbables.length ) {
88
87
  const next = isBefore
89
88
  ? tabbables[ 0 ]
@@ -125,20 +124,26 @@ export default function useTabNav() {
125
124
  return;
126
125
  }
127
126
 
128
- if ( ! hasMultiSelection() && ! getSelectedBlockClientId() ) {
127
+ if (
128
+ // Bails in case the focus capture elements aren’t present. They
129
+ // may be omitted to avoid silent tab stops in preview mode.
130
+ // See: https://github.com/WordPress/gutenberg/pull/59317
131
+ ! focusCaptureAfterRef.current ||
132
+ ! focusCaptureBeforeRef.current
133
+ ) {
129
134
  return;
130
135
  }
131
136
 
132
- const isShift = event.shiftKey;
137
+ const { target, shiftKey: isShift } = event;
133
138
  const direction = isShift ? 'findPrevious' : 'findNext';
134
- const nextTabbable = focus.tabbable[ direction ]( event.target );
139
+ const nextTabbable = focus.tabbable[ direction ]( target );
135
140
 
136
141
  // We want to constrain the tabbing to the block and its child blocks.
137
142
  // If the preceding form element is within a different block,
138
143
  // such as two sibling image blocks in the placeholder state,
139
144
  // we want shift + tab from the first form element to move to the image
140
145
  // block toolbar and not the previous image block's form element.
141
- const currentBlock = event.target.closest( '[data-block]' );
146
+ const currentBlock = target.closest( '[data-block]' );
142
147
  const isElementPartOfSelectedBlock =
143
148
  currentBlock &&
144
149
  nextTabbable &&
@@ -157,7 +162,6 @@ export default function useTabNav() {
157
162
  ) {
158
163
  return;
159
164
  }
160
-
161
165
  const next = isShift ? focusCaptureBeforeRef : focusCaptureAfterRef;
162
166
 
163
167
  // Disable focus capturing on the focus capture element, so it
@@ -180,6 +184,7 @@ export default function useTabNav() {
180
184
  // the writing flow wrapper.
181
185
  if (
182
186
  ! event.relatedTarget &&
187
+ event.target.hasAttribute( 'data-block' ) &&
183
188
  ownerDocument.activeElement === ownerDocument.body &&
184
189
  getBlockCount() === 0
185
190
  ) {
@@ -204,7 +209,7 @@ export default function useTabNav() {
204
209
  return;
205
210
  }
206
211
 
207
- if ( container.current === event.target ) {
212
+ if ( containerRef.current === event.target ) {
208
213
  return;
209
214
  }
210
215
 
@@ -233,7 +238,7 @@ export default function useTabNav() {
233
238
  };
234
239
  }, [] );
235
240
 
236
- const mergedRefs = useMergeRefs( [ container, ref ] );
241
+ const mergedRefs = useMergeRefs( [ containerRef, ref ] );
237
242
 
238
243
  return [ before, mergedRefs, after ];
239
244
  }