@wordpress/editor 14.33.4 → 14.33.6

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 (97) hide show
  1. package/build/components/collab-sidebar/add-comment.js +10 -12
  2. package/build/components/collab-sidebar/add-comment.js.map +2 -2
  3. package/build/components/collab-sidebar/comment-menu-item.js +36 -6
  4. package/build/components/collab-sidebar/comment-menu-item.js.map +3 -3
  5. package/build/components/collab-sidebar/comments.js +316 -318
  6. package/build/components/collab-sidebar/comments.js.map +3 -3
  7. package/build/components/collab-sidebar/index.js +38 -25
  8. package/build/components/collab-sidebar/index.js.map +3 -3
  9. package/build/components/collab-sidebar/utils.js +1 -1
  10. package/build/components/collab-sidebar/utils.js.map +2 -2
  11. package/build/components/editor/index.js +2 -2
  12. package/build/components/editor/index.js.map +3 -3
  13. package/build/components/post-excerpt/panel.js +1 -6
  14. package/build/components/post-excerpt/panel.js.map +2 -2
  15. package/build/components/post-template/block-theme.js +4 -32
  16. package/build/components/post-template/block-theme.js.map +3 -3
  17. package/build/components/post-template/create-new-template-modal.js +1 -2
  18. package/build/components/post-template/create-new-template-modal.js.map +2 -2
  19. package/build/components/post-template/hooks.js +1 -3
  20. package/build/components/post-template/hooks.js.map +2 -2
  21. package/build/components/preferences-modal/index.js +1 -1
  22. package/build/components/preferences-modal/index.js.map +1 -1
  23. package/build/components/provider/index.js +2 -3
  24. package/build/components/provider/index.js.map +2 -2
  25. package/build/components/start-page-options/index.js +4 -5
  26. package/build/components/start-page-options/index.js.map +2 -2
  27. package/build/dataviews/store/private-actions.js +3 -9
  28. package/build/dataviews/store/private-actions.js.map +2 -2
  29. package/build/store/actions.js +2 -67
  30. package/build/store/actions.js.map +2 -2
  31. package/build-module/components/collab-sidebar/add-comment.js +10 -12
  32. package/build-module/components/collab-sidebar/add-comment.js.map +2 -2
  33. package/build-module/components/collab-sidebar/comment-menu-item.js +40 -7
  34. package/build-module/components/collab-sidebar/comment-menu-item.js.map +2 -2
  35. package/build-module/components/collab-sidebar/comments.js +316 -318
  36. package/build-module/components/collab-sidebar/comments.js.map +2 -2
  37. package/build-module/components/collab-sidebar/index.js +38 -25
  38. package/build-module/components/collab-sidebar/index.js.map +2 -2
  39. package/build-module/components/collab-sidebar/utils.js +1 -1
  40. package/build-module/components/collab-sidebar/utils.js.map +2 -2
  41. package/build-module/components/editor/index.js +2 -2
  42. package/build-module/components/editor/index.js.map +2 -2
  43. package/build-module/components/post-excerpt/panel.js +1 -6
  44. package/build-module/components/post-excerpt/panel.js.map +2 -2
  45. package/build-module/components/post-template/block-theme.js +4 -32
  46. package/build-module/components/post-template/block-theme.js.map +2 -2
  47. package/build-module/components/post-template/create-new-template-modal.js +1 -2
  48. package/build-module/components/post-template/create-new-template-modal.js.map +2 -2
  49. package/build-module/components/post-template/hooks.js +1 -3
  50. package/build-module/components/post-template/hooks.js.map +2 -2
  51. package/build-module/components/preferences-modal/index.js +1 -1
  52. package/build-module/components/preferences-modal/index.js.map +1 -1
  53. package/build-module/components/provider/index.js +2 -3
  54. package/build-module/components/provider/index.js.map +2 -2
  55. package/build-module/components/start-page-options/index.js +5 -6
  56. package/build-module/components/start-page-options/index.js.map +2 -2
  57. package/build-module/dataviews/store/private-actions.js +3 -9
  58. package/build-module/dataviews/store/private-actions.js.map +2 -2
  59. package/build-module/store/actions.js +3 -68
  60. package/build-module/store/actions.js.map +2 -2
  61. package/build-style/style-rtl.css +14 -2
  62. package/build-style/style.css +14 -2
  63. package/build-types/components/collab-sidebar/add-comment.d.ts +3 -3
  64. package/build-types/components/collab-sidebar/add-comment.d.ts.map +1 -1
  65. package/build-types/components/collab-sidebar/comment-menu-item.d.ts +3 -2
  66. package/build-types/components/collab-sidebar/comment-menu-item.d.ts.map +1 -1
  67. package/build-types/components/collab-sidebar/comments.d.ts +4 -4
  68. package/build-types/components/collab-sidebar/comments.d.ts.map +1 -1
  69. package/build-types/components/collab-sidebar/index.d.ts.map +1 -1
  70. package/build-types/components/collab-sidebar/utils.d.ts.map +1 -1
  71. package/build-types/components/post-excerpt/panel.d.ts.map +1 -1
  72. package/build-types/components/post-template/block-theme.d.ts.map +1 -1
  73. package/build-types/components/post-template/create-new-template-modal.d.ts.map +1 -1
  74. package/build-types/components/post-template/hooks.d.ts.map +1 -1
  75. package/build-types/components/provider/index.d.ts.map +1 -1
  76. package/build-types/components/start-page-options/index.d.ts.map +1 -1
  77. package/build-types/dataviews/store/private-actions.d.ts.map +1 -1
  78. package/build-types/store/actions.d.ts.map +1 -1
  79. package/package.json +14 -14
  80. package/src/components/collab-sidebar/add-comment.js +10 -12
  81. package/src/components/collab-sidebar/comment-menu-item.js +51 -11
  82. package/src/components/collab-sidebar/comments.js +53 -56
  83. package/src/components/collab-sidebar/index.js +66 -46
  84. package/src/components/collab-sidebar/style.scss +16 -0
  85. package/src/components/collab-sidebar/utils.js +3 -2
  86. package/src/components/editor/index.js +1 -1
  87. package/src/components/post-excerpt/panel.js +1 -11
  88. package/src/components/post-template/block-theme.js +3 -45
  89. package/src/components/post-template/create-new-template-modal.js +0 -1
  90. package/src/components/post-template/hooks.js +1 -3
  91. package/src/components/preferences-modal/index.js +1 -1
  92. package/src/components/provider/index.js +2 -5
  93. package/src/components/start-page-options/index.js +5 -6
  94. package/src/components/start-page-options/style.scss +1 -1
  95. package/src/dataviews/store/private-actions.ts +7 -16
  96. package/src/store/actions.js +3 -100
  97. package/tsconfig.tsbuildinfo +1 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wordpress/editor",
3
- "version": "14.33.4",
3
+ "version": "14.33.6",
4
4
  "description": "Enhanced block editor for WordPress posts.",
5
5
  "author": "The WordPress Contributors",
6
6
  "license": "GPL-2.0-or-later",
@@ -57,35 +57,35 @@
57
57
  "@wordpress/api-fetch": "^7.33.1",
58
58
  "@wordpress/base-styles": "^6.9.1",
59
59
  "@wordpress/blob": "^4.33.1",
60
- "@wordpress/block-editor": "^15.6.2",
60
+ "@wordpress/block-editor": "^15.6.4",
61
61
  "@wordpress/blocks": "^15.6.1",
62
- "@wordpress/commands": "^1.33.1",
63
- "@wordpress/components": "^30.6.1",
62
+ "@wordpress/commands": "^1.33.2",
63
+ "@wordpress/components": "^30.6.2",
64
64
  "@wordpress/compose": "^7.33.1",
65
- "@wordpress/core-data": "^7.33.2",
65
+ "@wordpress/core-data": "^7.33.4",
66
66
  "@wordpress/data": "^10.33.1",
67
- "@wordpress/dataviews": "^10.1.2",
67
+ "@wordpress/dataviews": "^10.1.3",
68
68
  "@wordpress/date": "^5.33.1",
69
69
  "@wordpress/deprecated": "^4.33.1",
70
70
  "@wordpress/dom": "^4.33.1",
71
71
  "@wordpress/element": "^6.33.1",
72
- "@wordpress/fields": "^0.25.4",
72
+ "@wordpress/fields": "^0.25.6",
73
73
  "@wordpress/hooks": "^4.33.1",
74
74
  "@wordpress/html-entities": "^4.33.1",
75
75
  "@wordpress/i18n": "^6.6.1",
76
76
  "@wordpress/icons": "^11.0.1",
77
- "@wordpress/interface": "^9.18.1",
77
+ "@wordpress/interface": "^9.18.2",
78
78
  "@wordpress/keyboard-shortcuts": "^5.33.1",
79
79
  "@wordpress/keycodes": "^4.33.1",
80
80
  "@wordpress/media-utils": "^5.33.1",
81
81
  "@wordpress/notices": "^5.33.1",
82
- "@wordpress/patterns": "^2.33.2",
83
- "@wordpress/plugins": "^7.33.1",
84
- "@wordpress/preferences": "^4.33.1",
82
+ "@wordpress/patterns": "^2.33.4",
83
+ "@wordpress/plugins": "^7.33.2",
84
+ "@wordpress/preferences": "^4.33.2",
85
85
  "@wordpress/private-apis": "^1.33.1",
86
- "@wordpress/reusable-blocks": "^5.33.2",
86
+ "@wordpress/reusable-blocks": "^5.33.4",
87
87
  "@wordpress/rich-text": "^7.33.1",
88
- "@wordpress/server-side-render": "^6.9.1",
88
+ "@wordpress/server-side-render": "^6.9.2",
89
89
  "@wordpress/url": "^4.33.1",
90
90
  "@wordpress/warning": "^3.33.1",
91
91
  "@wordpress/wordcount": "^4.33.1",
@@ -108,5 +108,5 @@
108
108
  "publishConfig": {
109
109
  "access": "public"
110
110
  },
111
- "gitHead": "45005cc254bab59182927e35a68cd22f6320634d"
111
+ "gitHead": "2e2a11a11f0c5c9cb2bba2dd40b8046d2a10dc9d"
112
112
  }
@@ -28,32 +28,30 @@ const { useBlockElement } = unlock( blockEditorPrivateApis );
28
28
 
29
29
  export function AddComment( {
30
30
  onSubmit,
31
- showCommentBoard,
32
- setShowCommentBoard,
31
+ newNoteFormState,
32
+ setNewNoteFormState,
33
33
  commentSidebarRef,
34
34
  reflowComments = noop,
35
35
  isFloating = false,
36
36
  y,
37
37
  refs,
38
38
  } ) {
39
- const { clientId, blockCommentId } = useSelect( ( select ) => {
40
- const { getSelectedBlock } = select( blockEditorStore );
41
- const selectedBlock = getSelectedBlock();
39
+ const { clientId } = useSelect( ( select ) => {
40
+ const { getSelectedBlockClientId } = select( blockEditorStore );
42
41
  return {
43
- clientId: selectedBlock?.clientId,
44
- blockCommentId: selectedBlock?.attributes?.metadata?.noteId,
42
+ clientId: getSelectedBlockClientId(),
45
43
  };
46
44
  }, [] );
47
45
  const blockElement = useBlockElement( clientId );
48
46
  const { toggleBlockSpotlight } = unlock( useDispatch( blockEditorStore ) );
49
47
 
50
48
  const unselectThread = () => {
51
- setShowCommentBoard( false );
49
+ setNewNoteFormState( 'closed' );
52
50
  blockElement?.focus();
53
51
  toggleBlockSpotlight( clientId, false );
54
52
  };
55
53
 
56
- if ( ! showCommentBoard || ! clientId || undefined !== blockCommentId ) {
54
+ if ( newNoteFormState !== 'open' || ! clientId ) {
57
55
  return null;
58
56
  }
59
57
 
@@ -68,7 +66,7 @@ export function AddComment( {
68
66
  spacing="3"
69
67
  tabIndex={ 0 }
70
68
  aria-label={ __( 'New note' ) }
71
- role="listitem"
69
+ role="treeitem"
72
70
  ref={ isFloating ? refs.setFloating : undefined }
73
71
  style={
74
72
  isFloating
@@ -81,7 +79,7 @@ export function AddComment( {
81
79
  return;
82
80
  }
83
81
  toggleBlockSpotlight( clientId, false );
84
- setShowCommentBoard( false );
82
+ setNewNoteFormState( 'closed' );
85
83
  } }
86
84
  >
87
85
  <HStack alignment="left" spacing="3">
@@ -91,7 +89,7 @@ export function AddComment( {
91
89
  onSubmit={ async ( inputComment ) => {
92
90
  const { id } = await onSubmit( { content: inputComment } );
93
91
  focusCommentThread( id, commentSidebarRef.current );
94
- setShowCommentBoard( false );
92
+ setNewNoteFormState( 'creating' );
95
93
  } }
96
94
  onCancel={ unselectThread }
97
95
  reflowComments={ reflowComments }
@@ -4,8 +4,12 @@
4
4
  import { MenuItem } from '@wordpress/components';
5
5
  import { __ } from '@wordpress/i18n';
6
6
  import { comment as commentIcon } from '@wordpress/icons';
7
-
8
- import { privateApis as blockEditorPrivateApis } from '@wordpress/block-editor';
7
+ import {
8
+ privateApis as blockEditorPrivateApis,
9
+ store as blockEditorStore,
10
+ } from '@wordpress/block-editor';
11
+ import { useSelect } from '@wordpress/data';
12
+ import { getUnregisteredTypeHandlerName } from '@wordpress/blocks';
9
13
 
10
14
  /**
11
15
  * Internal dependencies
@@ -14,23 +18,59 @@ import { unlock } from '../../lock-unlock';
14
18
 
15
19
  const { CommentIconSlotFill } = unlock( blockEditorPrivateApis );
16
20
 
17
- const AddCommentMenuItem = ( { onClick } ) => {
21
+ const AddCommentMenuItem = ( { clientId, onClick, isDistractionFree } ) => {
22
+ const block = useSelect(
23
+ ( select ) => {
24
+ return select( blockEditorStore ).getBlock( clientId );
25
+ },
26
+ [ clientId ]
27
+ );
28
+
29
+ if (
30
+ ! block?.isValid ||
31
+ block?.name === getUnregisteredTypeHandlerName()
32
+ ) {
33
+ return null;
34
+ }
35
+
36
+ const isDisabled = isDistractionFree || block?.name === 'core/freeform';
37
+
38
+ let infoText;
39
+
40
+ if ( isDistractionFree ) {
41
+ infoText = __( 'Notes are disabled in distraction free mode.' );
42
+ } else if ( block?.name === 'core/freeform' ) {
43
+ infoText = __( 'Convert to blocks to add notes.' );
44
+ }
45
+
46
+ return (
47
+ <MenuItem
48
+ icon={ commentIcon }
49
+ onClick={ onClick }
50
+ aria-haspopup="dialog"
51
+ disabled={ isDisabled }
52
+ info={ infoText }
53
+ >
54
+ { __( 'Add note' ) }
55
+ </MenuItem>
56
+ );
57
+ };
58
+
59
+ const AddCommentMenuItemFill = ( { onClick, isDistractionFree } ) => {
18
60
  return (
19
61
  <CommentIconSlotFill.Fill>
20
- { ( { onClose } ) => (
21
- <MenuItem
22
- icon={ commentIcon }
62
+ { ( { clientId, onClose } ) => (
63
+ <AddCommentMenuItem
64
+ clientId={ clientId }
65
+ isDistractionFree={ isDistractionFree }
23
66
  onClick={ () => {
24
67
  onClick();
25
68
  onClose();
26
69
  } }
27
- aria-haspopup="dialog"
28
- >
29
- { __( 'Add note' ) }
30
- </MenuItem>
70
+ />
31
71
  ) }
32
72
  </CommentIconSlotFill.Fill>
33
73
  );
34
74
  };
35
75
 
36
- export default AddCommentMenuItem;
76
+ export default AddCommentMenuItemFill;
@@ -53,8 +53,8 @@ export function Comments( {
53
53
  onEditComment,
54
54
  onAddReply,
55
55
  onCommentDelete,
56
- showCommentBoard,
57
- setShowCommentBoard,
56
+ newNoteFormState,
57
+ setNewNoteFormState,
58
58
  commentSidebarRef,
59
59
  reflowComments,
60
60
  isFloating = false,
@@ -68,15 +68,18 @@ export function Comments( {
68
68
  const { setCanvasMinHeight } = unlock( useDispatch( editorStore ) );
69
69
  const { blockCommentId, selectedBlockClientId, orderedBlockIds } =
70
70
  useSelect( ( select ) => {
71
- const { getBlockAttributes, getSelectedBlockClientId } =
72
- select( blockEditorStore );
71
+ const {
72
+ getBlockAttributes,
73
+ getSelectedBlockClientId,
74
+ getClientIdsWithDescendants,
75
+ } = select( blockEditorStore );
73
76
  const clientId = getSelectedBlockClientId();
74
77
  return {
75
78
  blockCommentId: clientId
76
79
  ? getBlockAttributes( clientId )?.metadata?.noteId
77
80
  : null,
78
81
  selectedBlockClientId: clientId,
79
- orderedBlockIds: select( blockEditorStore ).getBlockOrder(),
82
+ orderedBlockIds: getClientIdsWithDescendants(),
80
83
  };
81
84
  }, [] );
82
85
 
@@ -90,7 +93,7 @@ export function Comments( {
90
93
  // add a "new note" entry to the threads. This special thread type
91
94
  // gets sorted and floated like regular threads, but shows an AddComment
92
95
  // component instead of a regular comment thread.
93
- if ( isFloating && showCommentBoard && undefined === blockCommentId ) {
96
+ if ( isFloating && newNoteFormState === 'open' ) {
94
97
  // Insert the new note entry at the correct location for its blockId.
95
98
  const newNoteThread = {
96
99
  id: 'new-note-thread',
@@ -116,8 +119,7 @@ export function Comments( {
116
119
  }, [
117
120
  noteThreads,
118
121
  isFloating,
119
- showCommentBoard,
120
- blockCommentId,
122
+ newNoteFormState,
121
123
  selectedBlockClientId,
122
124
  orderedBlockIds,
123
125
  ] );
@@ -144,7 +146,7 @@ export function Comments( {
144
146
  focusCommentThread( prevThread.id, commentSidebarRef.current );
145
147
  } else {
146
148
  setSelectedThread( null );
147
- setShowCommentBoard( false );
149
+ setNewNoteFormState( 'closed' );
148
150
  // Move focus to the related block.
149
151
  relatedBlockElement?.focus();
150
152
  }
@@ -153,9 +155,10 @@ export function Comments( {
153
155
  // Auto-select the related comment thread when a block is selected.
154
156
  useEffect( () => {
155
157
  // Fallback to 'new-note-thread' when showing the comment board for a new note.
156
- const fallback = showCommentBoard ? 'new-note-thread' : null;
157
- setSelectedThread( blockCommentId ?? fallback );
158
- }, [ blockCommentId, showCommentBoard ] );
158
+ setSelectedThread(
159
+ newNoteFormState === 'open' ? 'new-note-thread' : blockCommentId
160
+ );
161
+ }, [ blockCommentId, newNoteFormState ] );
159
162
 
160
163
  const setBlockRef = useCallback( ( id, blockRef ) => {
161
164
  setBlockRefs( ( prev ) => ( { ...prev, [ id ]: blockRef } ) );
@@ -308,35 +311,21 @@ export function Comments( {
308
311
  ] );
309
312
 
310
313
  const hasThreads = Array.isArray( threads ) && threads.length > 0;
314
+ // This should no longer happen since https://github.com/WordPress/gutenberg/pull/72872.
311
315
  if ( ! hasThreads && ! isFloating ) {
312
- return (
313
- <>
314
- <AddComment
315
- onSubmit={ onAddReply }
316
- showCommentBoard={ showCommentBoard }
317
- setShowCommentBoard={ setShowCommentBoard }
318
- commentSidebarRef={ commentSidebarRef }
319
- />
320
- <Text as="p">{ __( 'No notes available.' ) }</Text>
321
- <Text as="p" variant="muted">
322
- { __( 'Only logged in users can see Notes.' ) }
323
- </Text>
324
- </>
325
- );
316
+ return null;
326
317
  }
327
318
 
328
319
  return (
329
320
  <>
330
- { ! isFloating &&
331
- showCommentBoard &&
332
- undefined === blockCommentId && (
333
- <AddComment
334
- onSubmit={ onAddReply }
335
- showCommentBoard={ showCommentBoard }
336
- setShowCommentBoard={ setShowCommentBoard }
337
- commentSidebarRef={ commentSidebarRef }
338
- />
339
- ) }
321
+ { ! isFloating && newNoteFormState === 'open' && (
322
+ <AddComment
323
+ onSubmit={ onAddReply }
324
+ newNoteFormState={ newNoteFormState }
325
+ setNewNoteFormState={ setNewNoteFormState }
326
+ commentSidebarRef={ commentSidebarRef }
327
+ />
328
+ ) }
340
329
  { threads.map( ( thread ) => (
341
330
  <Thread
342
331
  key={ thread.id }
@@ -346,7 +335,7 @@ export function Comments( {
346
335
  onEditComment={ onEditComment }
347
336
  isSelected={ selectedThread === thread.id }
348
337
  setSelectedThread={ setSelectedThread }
349
- setShowCommentBoard={ setShowCommentBoard }
338
+ setNewNoteFormState={ setNewNoteFormState }
350
339
  commentSidebarRef={ commentSidebarRef }
351
340
  reflowComments={ reflowComments }
352
341
  isFloating={ isFloating }
@@ -355,7 +344,7 @@ export function Comments( {
355
344
  setBlockRef={ setBlockRef }
356
345
  selectedThread={ selectedThread }
357
346
  commentLastUpdated={ commentLastUpdated }
358
- showCommentBoard={ showCommentBoard }
347
+ newNoteFormState={ newNoteFormState }
359
348
  />
360
349
  ) ) }
361
350
  </>
@@ -368,7 +357,7 @@ function Thread( {
368
357
  onAddReply,
369
358
  onCommentDelete,
370
359
  isSelected,
371
- setShowCommentBoard,
360
+ setNewNoteFormState,
372
361
  commentSidebarRef,
373
362
  reflowComments,
374
363
  isFloating,
@@ -378,7 +367,7 @@ function Thread( {
378
367
  setSelectedThread,
379
368
  selectedThread,
380
369
  commentLastUpdated,
381
- showCommentBoard,
370
+ newNoteFormState,
382
371
  } ) {
383
372
  const { toggleBlockHighlight, selectBlock, toggleBlockSpotlight } = unlock(
384
373
  useDispatch( blockEditorStore )
@@ -406,7 +395,7 @@ function Thread( {
406
395
  };
407
396
 
408
397
  const handleCommentSelect = () => {
409
- setShowCommentBoard( false );
398
+ setNewNoteFormState( 'closed' );
410
399
  setSelectedThread( thread.id );
411
400
  if ( !! thread.blockClientId ) {
412
401
  // Pass `null` as the second parameter to prevent focusing the block.
@@ -417,7 +406,7 @@ function Thread( {
417
406
 
418
407
  const unselectThread = () => {
419
408
  setSelectedThread( null );
420
- setShowCommentBoard( false );
409
+ setNewNoteFormState( 'closed' );
421
410
  toggleBlockSpotlight( thread.blockClientId, false );
422
411
  };
423
412
 
@@ -443,12 +432,16 @@ function Thread( {
443
432
  commentExcerpt
444
433
  );
445
434
 
446
- if ( 'new-note-thread' === thread.id && showCommentBoard && isFloating ) {
435
+ if (
436
+ thread.id === 'new-note-thread' &&
437
+ newNoteFormState === 'open' &&
438
+ isFloating
439
+ ) {
447
440
  return (
448
441
  <AddComment
449
442
  onSubmit={ onAddReply }
450
- showCommentBoard={ showCommentBoard }
451
- setShowCommentBoard={ setShowCommentBoard }
443
+ newNoteFormState={ newNoteFormState }
444
+ setNewNoteFormState={ setNewNoteFormState }
452
445
  commentSidebarRef={ commentSidebarRef }
453
446
  reflowComments={ reflowComments }
454
447
  isFloating={ isFloating }
@@ -459,8 +452,6 @@ function Thread( {
459
452
  }
460
453
 
461
454
  return (
462
- // Disable reason: role="listitem" does in fact support aria-expanded.
463
- // eslint-disable-next-line jsx-a11y/role-supports-aria-props
464
455
  <VStack
465
456
  className={ clsx( 'editor-collab-sidebar-panel__thread', {
466
457
  'is-selected': isSelected,
@@ -495,7 +486,7 @@ function Thread( {
495
486
  }
496
487
  } }
497
488
  tabIndex={ 0 }
498
- role="listitem"
489
+ role="treeitem"
499
490
  aria-label={ ariaLabel }
500
491
  aria-expanded={ isSelected }
501
492
  ref={ isFloating ? refs.setFloating : undefined }
@@ -524,14 +515,17 @@ function Thread( {
524
515
  thread={ thread }
525
516
  isExpanded={ isSelected }
526
517
  onEdit={ ( params = {} ) => {
527
- const { status } = params;
528
518
  onEditComment( params );
529
- if ( status === 'approved' ) {
519
+ if ( params.status === 'approved' ) {
530
520
  unselectThread();
531
- focusCommentThread(
532
- thread.id,
533
- commentSidebarRef.current
534
- );
521
+ if ( isFloating ) {
522
+ relatedBlockElement?.focus();
523
+ } else {
524
+ focusCommentThread(
525
+ thread.id,
526
+ commentSidebarRef.current
527
+ );
528
+ }
535
529
  }
536
530
  } }
537
531
  onDelete={ onCommentDelete }
@@ -586,7 +580,7 @@ function Thread( {
586
580
  />
587
581
  ) }
588
582
  { isSelected && (
589
- <VStack spacing="2">
583
+ <VStack spacing="2" role="treeitem">
590
584
  <HStack alignment="left" spacing="3" justify="flex-start">
591
585
  <CommentAuthorInfo />
592
586
  </HStack>
@@ -716,7 +710,10 @@ const CommentBoard = ( {
716
710
  : [];
717
711
 
718
712
  return (
719
- <VStack spacing="2">
713
+ <VStack
714
+ spacing="2"
715
+ role={ thread.parent !== 0 ? 'treeitem' : undefined }
716
+ >
720
717
  <HStack alignment="left" spacing="3" justify="flex-start">
721
718
  <CommentAuthorInfo
722
719
  avatar={ thread?.author_avatar_urls?.[ 48 ] }
@@ -34,8 +34,8 @@ import PostTypeSupportCheck from '../post-type-support-check';
34
34
  import { unlock } from '../../lock-unlock';
35
35
 
36
36
  function NotesSidebarContent( {
37
- showCommentBoard,
38
- setShowCommentBoard,
37
+ newNoteFormState,
38
+ setNewNoteFormState,
39
39
  styles,
40
40
  comments,
41
41
  commentSidebarRef,
@@ -50,7 +50,7 @@ function NotesSidebarContent( {
50
50
  <VStack
51
51
  className="editor-collab-sidebar-panel"
52
52
  style={ styles }
53
- role="list"
53
+ role="tree"
54
54
  spacing="3"
55
55
  justify="flex-start"
56
56
  ref={ ( node ) => {
@@ -60,14 +60,17 @@ function NotesSidebarContent( {
60
60
  commentSidebarRef.current = node;
61
61
  }
62
62
  } }
63
+ aria-label={
64
+ isFloating ? __( 'Unresolved notes' ) : __( 'All notes' )
65
+ }
63
66
  >
64
67
  <Comments
65
68
  threads={ comments }
66
69
  onEditComment={ onEdit }
67
70
  onAddReply={ onCreate }
68
71
  onCommentDelete={ onDelete }
69
- showCommentBoard={ showCommentBoard }
70
- setShowCommentBoard={ setShowCommentBoard }
72
+ newNoteFormState={ newNoteFormState }
73
+ setNewNoteFormState={ setNewNoteFormState }
71
74
  commentSidebarRef={ commentSidebarRef }
72
75
  reflowComments={ reflowComments }
73
76
  commentLastUpdated={ commentLastUpdated }
@@ -78,7 +81,8 @@ function NotesSidebarContent( {
78
81
  }
79
82
 
80
83
  function NotesSidebar( { postId, mode } ) {
81
- const [ showCommentBoard, setShowCommentBoard ] = useState( false );
84
+ // Enum: 'closed' | 'creating' | 'open'
85
+ const [ newNoteFormState, setNewNoteFormState ] = useState( 'closed' );
82
86
  const { getActiveComplementaryArea } = useSelect( interfaceStore );
83
87
  const { enableComplementaryArea } = useDispatch( interfaceStore );
84
88
  const { toggleBlockSpotlight } = unlock( useDispatch( blockEditorStore ) );
@@ -87,17 +91,24 @@ function NotesSidebar( { postId, mode } ) {
87
91
 
88
92
  const showFloatingSidebar = isLargeViewport && mode === 'post-only';
89
93
 
90
- const { clientId, blockCommentId } = useSelect( ( select ) => {
91
- const { getBlockAttributes, getSelectedBlockClientId } =
92
- select( blockEditorStore );
93
- const _clientId = getSelectedBlockClientId();
94
- return {
95
- clientId: _clientId,
96
- blockCommentId: _clientId
97
- ? getBlockAttributes( _clientId )?.metadata?.noteId
98
- : null,
99
- };
100
- }, [] );
94
+ const { clientId, blockCommentId, isDistractionFree } = useSelect(
95
+ ( select ) => {
96
+ const {
97
+ getBlockAttributes,
98
+ getSelectedBlockClientId,
99
+ getSettings,
100
+ } = select( blockEditorStore );
101
+ const _clientId = getSelectedBlockClientId();
102
+ return {
103
+ clientId: _clientId,
104
+ blockCommentId: _clientId
105
+ ? getBlockAttributes( _clientId )?.metadata?.noteId
106
+ : null,
107
+ isDistractionFree: getSettings().isDistractionFree,
108
+ };
109
+ },
110
+ []
111
+ );
101
112
 
102
113
  const {
103
114
  resultComments,
@@ -107,7 +118,8 @@ function NotesSidebar( { postId, mode } ) {
107
118
  } = useBlockComments( postId );
108
119
  useEnableFloatingSidebar(
109
120
  showFloatingSidebar &&
110
- ( unresolvedSortedThreads.length > 0 || showCommentBoard )
121
+ ( unresolvedSortedThreads.length > 0 ||
122
+ newNoteFormState !== 'closed' )
111
123
  );
112
124
 
113
125
  // Get the global styles to set the background color of the sidebar.
@@ -118,6 +130,8 @@ function NotesSidebar( { postId, mode } ) {
118
130
  const currentThread = blockCommentId
119
131
  ? resultComments.find( ( thread ) => thread.id === blockCommentId )
120
132
  : null;
133
+ const showAllNotesSidebar =
134
+ resultComments.length > 0 || ! showFloatingSidebar;
121
135
 
122
136
  async function openTheSidebar() {
123
137
  const prevArea = await getActiveComplementaryArea( 'core' );
@@ -125,7 +139,7 @@ function NotesSidebar( { postId, mode } ) {
125
139
 
126
140
  if ( currentThread?.status === 'approved' ) {
127
141
  enableComplementaryArea( 'core', collabHistorySidebarName );
128
- } else if ( ! activeNotesArea ) {
142
+ } else if ( ! activeNotesArea || ! showAllNotesSidebar ) {
129
143
  enableComplementaryArea(
130
144
  'core',
131
145
  showFloatingSidebar
@@ -140,46 +154,52 @@ function NotesSidebar( { postId, mode } ) {
140
154
  return;
141
155
  }
142
156
 
143
- setShowCommentBoard( ! blockCommentId );
157
+ setNewNoteFormState( ! currentThread ? 'open' : 'closed' );
144
158
  focusCommentThread(
145
- blockCommentId,
159
+ currentThread?.id,
146
160
  commentSidebarRef.current,
147
161
  // Focus a comment thread when there's a selected block with a comment.
148
- ! blockCommentId ? 'textarea' : undefined
162
+ ! currentThread ? 'textarea' : undefined
149
163
  );
150
164
  toggleBlockSpotlight( clientId, true );
151
165
  }
152
166
 
167
+ if ( isDistractionFree ) {
168
+ return <AddCommentMenuItem isDistractionFree />;
169
+ }
170
+
153
171
  return (
154
172
  <>
155
- { blockCommentId && (
173
+ { !! currentThread && (
156
174
  <CommentAvatarIndicator
157
175
  thread={ currentThread }
158
176
  onClick={ openTheSidebar }
159
177
  />
160
178
  ) }
161
179
  <AddCommentMenuItem onClick={ openTheSidebar } />
162
- <PluginSidebar
163
- identifier={ collabHistorySidebarName }
164
- name={ collabHistorySidebarName }
165
- title={ __( 'All notes' ) }
166
- header={
167
- <h2 className="interface-complementary-area-header__title">
168
- { __( 'All notes' ) }
169
- </h2>
170
- }
171
- icon={ commentIcon }
172
- closeLabel={ __( 'Close Notes' ) }
173
- >
174
- <NotesSidebarContent
175
- comments={ resultComments }
176
- showCommentBoard={ showCommentBoard }
177
- setShowCommentBoard={ setShowCommentBoard }
178
- commentSidebarRef={ commentSidebarRef }
179
- reflowComments={ reflowComments }
180
- commentLastUpdated={ commentLastUpdated }
181
- />
182
- </PluginSidebar>
180
+ { showAllNotesSidebar && (
181
+ <PluginSidebar
182
+ identifier={ collabHistorySidebarName }
183
+ name={ collabHistorySidebarName }
184
+ title={ __( 'All notes' ) }
185
+ header={
186
+ <h2 className="interface-complementary-area-header__title">
187
+ { __( 'All notes' ) }
188
+ </h2>
189
+ }
190
+ icon={ commentIcon }
191
+ closeLabel={ __( 'Close Notes' ) }
192
+ >
193
+ <NotesSidebarContent
194
+ comments={ resultComments }
195
+ newNoteFormState={ newNoteFormState }
196
+ setNewNoteFormState={ setNewNoteFormState }
197
+ commentSidebarRef={ commentSidebarRef }
198
+ reflowComments={ reflowComments }
199
+ commentLastUpdated={ commentLastUpdated }
200
+ />
201
+ </PluginSidebar>
202
+ ) }
183
203
  { isLargeViewport && (
184
204
  <PluginSidebar
185
205
  isPinnable={ false }
@@ -191,8 +211,8 @@ function NotesSidebar( { postId, mode } ) {
191
211
  >
192
212
  <NotesSidebarContent
193
213
  comments={ unresolvedSortedThreads }
194
- showCommentBoard={ showCommentBoard }
195
- setShowCommentBoard={ setShowCommentBoard }
214
+ newNoteFormState={ newNoteFormState }
215
+ setNewNoteFormState={ setNewNoteFormState }
196
216
  commentSidebarRef={ commentSidebarRef }
197
217
  reflowComments={ reflowComments }
198
218
  commentLastUpdated={ commentLastUpdated }