@wordpress/editor 14.33.3 → 14.33.5

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 (107) hide show
  1. package/build/bindings/post-data.js +47 -63
  2. package/build/bindings/post-data.js.map +3 -3
  3. package/build/bindings/post-meta.js +45 -39
  4. package/build/bindings/post-meta.js.map +2 -2
  5. package/build/components/collab-sidebar/add-comment.js +9 -5
  6. package/build/components/collab-sidebar/add-comment.js.map +2 -2
  7. package/build/components/collab-sidebar/comment-author-info.js +27 -15
  8. package/build/components/collab-sidebar/comment-author-info.js.map +2 -2
  9. package/build/components/collab-sidebar/comment-indicator-toolbar.js +9 -23
  10. package/build/components/collab-sidebar/comment-indicator-toolbar.js.map +3 -3
  11. package/build/components/collab-sidebar/comment-menu-item.js +36 -6
  12. package/build/components/collab-sidebar/comment-menu-item.js.map +3 -3
  13. package/build/components/collab-sidebar/comments.js +317 -301
  14. package/build/components/collab-sidebar/comments.js.map +3 -3
  15. package/build/components/collab-sidebar/hooks.js +5 -3
  16. package/build/components/collab-sidebar/hooks.js.map +2 -2
  17. package/build/components/collab-sidebar/index.js +35 -11
  18. package/build/components/collab-sidebar/index.js.map +3 -3
  19. package/build/components/collab-sidebar/utils.js +6 -3
  20. package/build/components/collab-sidebar/utils.js.map +2 -2
  21. package/build/components/editor/index.js +2 -2
  22. package/build/components/editor/index.js.map +3 -3
  23. package/build/components/more-menu/index.js +1 -1
  24. package/build/components/more-menu/index.js.map +2 -2
  25. package/build/components/visual-editor/index.js +20 -9
  26. package/build/components/visual-editor/index.js.map +2 -2
  27. package/build/store/private-actions.js +8 -0
  28. package/build/store/private-actions.js.map +2 -2
  29. package/build/store/private-selectors.js +5 -0
  30. package/build/store/private-selectors.js.map +2 -2
  31. package/build/store/reducer.js +10 -0
  32. package/build/store/reducer.js.map +2 -2
  33. package/build-module/bindings/post-data.js +47 -63
  34. package/build-module/bindings/post-data.js.map +2 -2
  35. package/build-module/bindings/post-meta.js +45 -39
  36. package/build-module/bindings/post-meta.js.map +2 -2
  37. package/build-module/components/collab-sidebar/add-comment.js +10 -6
  38. package/build-module/components/collab-sidebar/add-comment.js.map +2 -2
  39. package/build-module/components/collab-sidebar/comment-author-info.js +27 -15
  40. package/build-module/components/collab-sidebar/comment-author-info.js.map +2 -2
  41. package/build-module/components/collab-sidebar/comment-indicator-toolbar.js +15 -25
  42. package/build-module/components/collab-sidebar/comment-indicator-toolbar.js.map +2 -2
  43. package/build-module/components/collab-sidebar/comment-menu-item.js +40 -7
  44. package/build-module/components/collab-sidebar/comment-menu-item.js.map +2 -2
  45. package/build-module/components/collab-sidebar/comments.js +319 -302
  46. package/build-module/components/collab-sidebar/comments.js.map +2 -2
  47. package/build-module/components/collab-sidebar/hooks.js +5 -3
  48. package/build-module/components/collab-sidebar/hooks.js.map +2 -2
  49. package/build-module/components/collab-sidebar/index.js +35 -11
  50. package/build-module/components/collab-sidebar/index.js.map +2 -2
  51. package/build-module/components/collab-sidebar/utils.js +6 -3
  52. package/build-module/components/collab-sidebar/utils.js.map +2 -2
  53. package/build-module/components/editor/index.js +2 -2
  54. package/build-module/components/editor/index.js.map +2 -2
  55. package/build-module/components/more-menu/index.js +1 -1
  56. package/build-module/components/more-menu/index.js.map +2 -2
  57. package/build-module/components/visual-editor/index.js +20 -9
  58. package/build-module/components/visual-editor/index.js.map +2 -2
  59. package/build-module/store/private-actions.js +7 -0
  60. package/build-module/store/private-actions.js.map +2 -2
  61. package/build-module/store/private-selectors.js +4 -0
  62. package/build-module/store/private-selectors.js.map +2 -2
  63. package/build-module/store/reducer.js +9 -0
  64. package/build-module/store/reducer.js.map +2 -2
  65. package/build-style/style-rtl.css +6 -43
  66. package/build-style/style.css +6 -43
  67. package/build-types/bindings/post-data.d.ts +18 -8
  68. package/build-types/bindings/post-meta.d.ts +1 -7
  69. package/build-types/components/collab-sidebar/add-comment.d.ts.map +1 -1
  70. package/build-types/components/collab-sidebar/comment-author-info.d.ts +5 -16
  71. package/build-types/components/collab-sidebar/comment-author-info.d.ts.map +1 -1
  72. package/build-types/components/collab-sidebar/comment-indicator-toolbar.d.ts.map +1 -1
  73. package/build-types/components/collab-sidebar/comment-menu-item.d.ts +3 -2
  74. package/build-types/components/collab-sidebar/comment-menu-item.d.ts.map +1 -1
  75. package/build-types/components/collab-sidebar/comments.d.ts +1 -1
  76. package/build-types/components/collab-sidebar/comments.d.ts.map +1 -1
  77. package/build-types/components/collab-sidebar/hooks.d.ts.map +1 -1
  78. package/build-types/components/collab-sidebar/index.d.ts.map +1 -1
  79. package/build-types/components/collab-sidebar/utils.d.ts +2 -2
  80. package/build-types/components/collab-sidebar/utils.d.ts.map +1 -1
  81. package/build-types/components/visual-editor/index.d.ts.map +1 -1
  82. package/build-types/store/private-actions.d.ts +7 -0
  83. package/build-types/store/private-actions.d.ts.map +1 -1
  84. package/build-types/store/private-selectors.d.ts +7 -0
  85. package/build-types/store/private-selectors.d.ts.map +1 -1
  86. package/build-types/store/reducer.d.ts +10 -0
  87. package/build-types/store/reducer.d.ts.map +1 -1
  88. package/package.json +8 -8
  89. package/src/bindings/post-data.js +63 -111
  90. package/src/bindings/post-meta.js +55 -46
  91. package/src/bindings/test/post-meta.js +211 -0
  92. package/src/components/collab-sidebar/add-comment.js +11 -6
  93. package/src/components/collab-sidebar/comment-author-info.js +33 -26
  94. package/src/components/collab-sidebar/comment-indicator-toolbar.js +19 -29
  95. package/src/components/collab-sidebar/comment-menu-item.js +51 -11
  96. package/src/components/collab-sidebar/comments.js +47 -27
  97. package/src/components/collab-sidebar/hooks.js +6 -4
  98. package/src/components/collab-sidebar/index.js +63 -27
  99. package/src/components/collab-sidebar/style.scss +6 -46
  100. package/src/components/collab-sidebar/utils.js +15 -5
  101. package/src/components/editor/index.js +1 -1
  102. package/src/components/more-menu/index.js +1 -1
  103. package/src/components/visual-editor/index.js +27 -6
  104. package/src/store/private-actions.js +13 -0
  105. package/src/store/private-selectors.js +10 -0
  106. package/src/store/reducer.js +16 -0
  107. package/tsconfig.tsbuildinfo +1 -1
@@ -5,7 +5,8 @@ import {
5
5
  RawHTML,
6
6
  useEffect,
7
7
  useCallback,
8
- useMemo
8
+ useMemo,
9
+ useRef
9
10
  } from "@wordpress/element";
10
11
  import {
11
12
  __experimentalText as Text,
@@ -31,6 +32,7 @@ import CommentForm from "./comment-form";
31
32
  import { focusCommentThread, getCommentExcerpt } from "./utils";
32
33
  import { useFloatingThread } from "./hooks";
33
34
  import { AddComment } from "./add-comment";
35
+ import { store as editorStore } from "../../store";
34
36
  const { useBlockElement } = unlock(blockEditorPrivateApis);
35
37
  const { Menu } = unlock(componentsPrivateApis);
36
38
  function Comments({
@@ -49,6 +51,7 @@ function Comments({
49
51
  const [selectedThread, setSelectedThread] = useState(null);
50
52
  const [boardOffsets, setBoardOffsets] = useState({});
51
53
  const [blockRefs, setBlockRefs] = useState({});
54
+ const { setCanvasMinHeight } = unlock(useDispatch(editorStore));
52
55
  const { blockCommentId, selectedBlockClientId, orderedBlockIds } = useSelect((select) => {
53
56
  const { getBlockAttributes, getSelectedBlockClientId } = select(blockEditorStore);
54
57
  const clientId = getSelectedBlockClientId();
@@ -114,8 +117,9 @@ function Comments({
114
117
  }
115
118
  };
116
119
  useEffect(() => {
117
- setSelectedThread(blockCommentId ?? void 0);
118
- }, [blockCommentId]);
120
+ const fallback = showCommentBoard ? "new-note-thread" : null;
121
+ setSelectedThread(blockCommentId ?? fallback);
122
+ }, [blockCommentId, showCommentBoard]);
119
123
  const setBlockRef = useCallback((id, blockRef) => {
120
124
  setBlockRefs((prev) => ({ ...prev, [id]: blockRef }));
121
125
  }, []);
@@ -123,7 +127,7 @@ function Comments({
123
127
  const calculateAllOffsets = () => {
124
128
  const offsets = {};
125
129
  if (!isFloating) {
126
- return offsets;
130
+ return { offsets, minHeight: 0 };
127
131
  }
128
132
  const selectedThreadIndex = threads.findIndex(
129
133
  (t) => t.id === selectedThread
@@ -131,7 +135,7 @@ function Comments({
131
135
  const breakIndex = selectedThreadIndex === -1 ? 0 : selectedThreadIndex;
132
136
  const selectedThreadData = threads[breakIndex];
133
137
  if (!selectedThreadData || !blockRefs[selectedThreadData.id]) {
134
- return offsets;
138
+ return { offsets, minHeight: 0 };
135
139
  }
136
140
  let blockElement = blockRefs[selectedThreadData.id];
137
141
  let blockRect = blockElement?.getBoundingClientRect();
@@ -184,28 +188,34 @@ function Comments({
184
188
  threadTop: threadTop + additionalOffset
185
189
  };
186
190
  }
187
- return offsets;
191
+ let editorMinHeight = 0;
192
+ const lastThread = threads[threads.length - 1];
193
+ if (blockRefs[lastThread.id]) {
194
+ const lastBlockElement = blockRefs[lastThread.id];
195
+ const lastBlockRect = lastBlockElement?.getBoundingClientRect();
196
+ const lastThreadTop = lastBlockRect?.top || 0;
197
+ const lastThreadHeight = heights[lastThread.id] || 0;
198
+ const lastThreadOffset = offsets[lastThread.id] || 0;
199
+ editorMinHeight = lastThreadTop + lastThreadHeight + lastThreadOffset + 32;
200
+ }
201
+ return { offsets, minHeight: editorMinHeight };
188
202
  };
189
- const newOffsets = calculateAllOffsets();
203
+ const { offsets: newOffsets, minHeight } = calculateAllOffsets();
190
204
  if (Object.keys(newOffsets).length > 0) {
191
205
  setBoardOffsets(newOffsets);
192
206
  }
193
- }, [heights, blockRefs, isFloating, threads, selectedThread]);
207
+ setCanvasMinHeight(minHeight);
208
+ }, [
209
+ heights,
210
+ blockRefs,
211
+ isFloating,
212
+ threads,
213
+ selectedThread,
214
+ setCanvasMinHeight
215
+ ]);
194
216
  const hasThreads = Array.isArray(threads) && threads.length > 0;
195
217
  if (!hasThreads && !isFloating) {
196
- return /* @__PURE__ */ jsxs(Fragment, { children: [
197
- /* @__PURE__ */ jsx(
198
- AddComment,
199
- {
200
- onSubmit: onAddReply,
201
- showCommentBoard,
202
- setShowCommentBoard,
203
- commentSidebarRef
204
- }
205
- ),
206
- /* @__PURE__ */ jsx(Text, { as: "p", children: __("No notes available.") }),
207
- /* @__PURE__ */ jsx(Text, { as: "p", variant: "muted", children: __("Only logged in users can see Notes.") })
208
- ] });
218
+ return null;
209
219
  }
210
220
  return /* @__PURE__ */ jsxs(Fragment, { children: [
211
221
  !isFloating && showCommentBoard && void 0 === blockCommentId && /* @__PURE__ */ jsx(
@@ -325,185 +335,181 @@ function Thread({
325
335
  }
326
336
  );
327
337
  }
328
- return (
329
- // Disable reason: role="listitem" does in fact support aria-expanded.
330
- // eslint-disable-next-line jsx-a11y/role-supports-aria-props
331
- /* @__PURE__ */ jsxs(
332
- VStack,
333
- {
334
- className: clsx("editor-collab-sidebar-panel__thread", {
335
- "is-selected": isSelected,
336
- "is-floating": isFloating
337
- }),
338
- id: `comment-thread-${thread.id}`,
339
- spacing: "3",
340
- onClick: handleCommentSelect,
341
- onMouseEnter,
342
- onMouseLeave,
343
- onFocus: onMouseEnter,
344
- onBlur: onMouseLeave,
345
- onKeyDown: (event) => {
346
- if (event.defaultPrevented) {
347
- return;
348
- }
349
- if (event.key === "Enter" && event.currentTarget === event.target) {
350
- if (isSelected) {
351
- unselectThread();
352
- } else {
353
- handleCommentSelect();
354
- }
355
- }
356
- if (event.key === "Escape") {
338
+ return /* @__PURE__ */ jsxs(
339
+ VStack,
340
+ {
341
+ className: clsx("editor-collab-sidebar-panel__thread", {
342
+ "is-selected": isSelected,
343
+ "is-floating": isFloating
344
+ }),
345
+ id: `comment-thread-${thread.id}`,
346
+ spacing: "3",
347
+ onClick: handleCommentSelect,
348
+ onMouseEnter,
349
+ onMouseLeave,
350
+ onFocus: onMouseEnter,
351
+ onBlur: onMouseLeave,
352
+ onKeyDown: (event) => {
353
+ if (event.defaultPrevented) {
354
+ return;
355
+ }
356
+ if (event.key === "Enter" && event.currentTarget === event.target) {
357
+ if (isSelected) {
357
358
  unselectThread();
358
- focusCommentThread(thread.id, commentSidebarRef.current);
359
+ } else {
360
+ handleCommentSelect();
359
361
  }
360
- },
361
- tabIndex: 0,
362
- role: "listitem",
363
- "aria-label": ariaLabel,
364
- "aria-expanded": isSelected,
365
- ref: isFloating ? refs.setFloating : void 0,
366
- style: isFloating ? { top: y } : void 0,
367
- children: [
368
- /* @__PURE__ */ jsx(
369
- Button,
370
- {
371
- className: "editor-collab-sidebar-panel__skip-to-comment",
372
- variant: "secondary",
373
- size: "compact",
374
- onClick: () => {
362
+ }
363
+ if (event.key === "Escape") {
364
+ unselectThread();
365
+ focusCommentThread(thread.id, commentSidebarRef.current);
366
+ }
367
+ },
368
+ tabIndex: 0,
369
+ role: "treeitem",
370
+ "aria-label": ariaLabel,
371
+ "aria-expanded": isSelected,
372
+ ref: isFloating ? refs.setFloating : void 0,
373
+ style: isFloating ? { top: y } : void 0,
374
+ children: [
375
+ /* @__PURE__ */ jsx(
376
+ Button,
377
+ {
378
+ className: "editor-collab-sidebar-panel__skip-to-comment",
379
+ variant: "secondary",
380
+ size: "compact",
381
+ onClick: () => {
382
+ focusCommentThread(
383
+ thread.id,
384
+ commentSidebarRef.current,
385
+ "textarea"
386
+ );
387
+ },
388
+ children: __("Add new note")
389
+ }
390
+ ),
391
+ !thread.blockClientId && /* @__PURE__ */ jsx(Text, { as: "p", weight: 500, variant: "muted", children: __("Original block deleted.") }),
392
+ /* @__PURE__ */ jsx(
393
+ CommentBoard,
394
+ {
395
+ thread,
396
+ isExpanded: isSelected,
397
+ onEdit: (params = {}) => {
398
+ const { status } = params;
399
+ onEditComment(params);
400
+ if (status === "approved") {
401
+ unselectThread();
375
402
  focusCommentThread(
376
403
  thread.id,
377
- commentSidebarRef.current,
378
- "textarea"
404
+ commentSidebarRef.current
379
405
  );
380
- },
381
- children: __("Add new note")
382
- }
383
- ),
384
- !thread.blockClientId && /* @__PURE__ */ jsx(Text, { as: "p", weight: 500, variant: "muted", children: __("Original block deleted.") }),
385
- /* @__PURE__ */ jsx(
386
- CommentBoard,
406
+ }
407
+ },
408
+ onDelete: onCommentDelete,
409
+ reflowComments
410
+ }
411
+ ),
412
+ isSelected && allReplies.map((reply) => /* @__PURE__ */ jsx(
413
+ CommentBoard,
414
+ {
415
+ thread: reply,
416
+ parent: thread,
417
+ isExpanded: isSelected,
418
+ onEdit: onEditComment,
419
+ onDelete: onCommentDelete,
420
+ reflowComments
421
+ },
422
+ reply.id
423
+ )),
424
+ !isSelected && restReplies.length > 0 && /* @__PURE__ */ jsx(HStack, { className: "editor-collab-sidebar-panel__more-reply-separator", children: /* @__PURE__ */ jsx(
425
+ Button,
426
+ {
427
+ size: "compact",
428
+ variant: "tertiary",
429
+ className: "editor-collab-sidebar-panel__more-reply-button",
430
+ onClick: () => {
431
+ setSelectedThread(thread.id);
432
+ focusCommentThread(
433
+ thread.id,
434
+ commentSidebarRef.current
435
+ );
436
+ },
437
+ children: sprintf(
438
+ // translators: %s: number of replies.
439
+ _n(
440
+ "%s more reply",
441
+ "%s more replies",
442
+ restReplies.length
443
+ ),
444
+ restReplies.length
445
+ )
446
+ }
447
+ ) }),
448
+ !isSelected && lastReply && /* @__PURE__ */ jsx(
449
+ CommentBoard,
450
+ {
451
+ thread: lastReply,
452
+ parent: thread,
453
+ isExpanded: isSelected,
454
+ onEdit: onEditComment,
455
+ onDelete: onCommentDelete,
456
+ reflowComments
457
+ }
458
+ ),
459
+ isSelected && /* @__PURE__ */ jsxs(VStack, { spacing: "2", role: "treeitem", children: [
460
+ /* @__PURE__ */ jsx(HStack, { alignment: "left", spacing: "3", justify: "flex-start", children: /* @__PURE__ */ jsx(CommentAuthorInfo, {}) }),
461
+ /* @__PURE__ */ jsx(VStack, { spacing: "2", children: /* @__PURE__ */ jsx(
462
+ CommentForm,
387
463
  {
388
- thread,
389
- isExpanded: isSelected,
390
- onEdit: (params = {}) => {
391
- const { status } = params;
392
- onEditComment(params);
393
- if (status === "approved") {
394
- unselectThread();
395
- focusCommentThread(
396
- thread.id,
397
- commentSidebarRef.current
398
- );
464
+ onSubmit: (inputComment) => {
465
+ if ("approved" === thread.status) {
466
+ onEditComment({
467
+ id: thread.id,
468
+ status: "hold",
469
+ content: inputComment
470
+ });
471
+ } else {
472
+ onAddReply({
473
+ content: inputComment,
474
+ parent: thread.id
475
+ });
399
476
  }
400
477
  },
401
- onDelete: onCommentDelete,
402
- reflowComments
403
- }
404
- ),
405
- isSelected && allReplies.map((reply) => /* @__PURE__ */ jsx(
406
- CommentBoard,
407
- {
408
- thread: reply,
409
- parent: thread,
410
- isExpanded: isSelected,
411
- onEdit: onEditComment,
412
- onDelete: onCommentDelete,
413
- reflowComments
414
- },
415
- reply.id
416
- )),
417
- !isSelected && restReplies.length > 0 && /* @__PURE__ */ jsx(HStack, { className: "editor-collab-sidebar-panel__more-reply-separator", children: /* @__PURE__ */ jsx(
418
- Button,
419
- {
420
- size: "compact",
421
- variant: "tertiary",
422
- className: "editor-collab-sidebar-panel__more-reply-button",
423
- onClick: () => {
424
- setSelectedThread(thread.id);
478
+ onCancel: (event) => {
479
+ event.stopPropagation();
480
+ unselectThread();
425
481
  focusCommentThread(
426
482
  thread.id,
427
483
  commentSidebarRef.current
428
484
  );
429
485
  },
430
- children: sprintf(
431
- // translators: %s: number of replies.
432
- _n(
433
- "%s more reply",
434
- "%s more replies",
435
- restReplies.length
436
- ),
437
- restReplies.length
438
- )
439
- }
440
- ) }),
441
- !isSelected && lastReply && /* @__PURE__ */ jsx(
442
- CommentBoard,
443
- {
444
- thread: lastReply,
445
- parent: thread,
446
- isExpanded: isSelected,
447
- onEdit: onEditComment,
448
- onDelete: onCommentDelete,
486
+ submitButtonText: "approved" === thread.status ? __("Reopen & Reply") : __("Reply"),
487
+ rows: "approved" === thread.status ? 2 : 4,
488
+ labelText: sprintf(
489
+ // translators: %1$s: note identifier, %2$s: author name
490
+ __("Reply to note %1$s by %2$s"),
491
+ thread.id,
492
+ thread.author_name
493
+ ),
449
494
  reflowComments
450
495
  }
451
- ),
452
- isSelected && /* @__PURE__ */ jsxs(VStack, { spacing: "2", children: [
453
- /* @__PURE__ */ jsx(HStack, { alignment: "left", spacing: "3", justify: "flex-start", children: /* @__PURE__ */ jsx(CommentAuthorInfo, {}) }),
454
- /* @__PURE__ */ jsx(VStack, { spacing: "2", children: /* @__PURE__ */ jsx(
455
- CommentForm,
456
- {
457
- onSubmit: (inputComment) => {
458
- if ("approved" === thread.status) {
459
- onEditComment({
460
- id: thread.id,
461
- status: "hold",
462
- content: inputComment
463
- });
464
- } else {
465
- onAddReply({
466
- content: inputComment,
467
- parent: thread.id
468
- });
469
- }
470
- },
471
- onCancel: (event) => {
472
- event.stopPropagation();
473
- unselectThread();
474
- focusCommentThread(
475
- thread.id,
476
- commentSidebarRef.current
477
- );
478
- },
479
- submitButtonText: "approved" === thread.status ? __("Reopen & Reply") : __("Reply"),
480
- rows: "approved" === thread.status ? 2 : 4,
481
- labelText: sprintf(
482
- // translators: %1$s: note identifier, %2$s: author name
483
- __("Reply to note %1$s by %2$s"),
484
- thread.id,
485
- thread.author_name
486
- ),
487
- reflowComments
488
- }
489
- ) })
490
- ] }),
491
- !!thread.blockClientId && /* @__PURE__ */ jsx(
492
- Button,
493
- {
494
- className: "editor-collab-sidebar-panel__skip-to-block",
495
- variant: "secondary",
496
- size: "compact",
497
- onClick: (event) => {
498
- event.stopPropagation();
499
- relatedBlockElement?.focus();
500
- },
501
- children: __("Back to block")
502
- }
503
- )
504
- ]
505
- }
506
- )
496
+ ) })
497
+ ] }),
498
+ !!thread.blockClientId && /* @__PURE__ */ jsx(
499
+ Button,
500
+ {
501
+ className: "editor-collab-sidebar-panel__skip-to-block",
502
+ variant: "secondary",
503
+ size: "compact",
504
+ onClick: (event) => {
505
+ event.stopPropagation();
506
+ relatedBlockElement?.focus();
507
+ },
508
+ children: __("Back to block")
509
+ }
510
+ )
511
+ ]
512
+ }
507
513
  );
508
514
  }
509
515
  const CommentBoard = ({
@@ -516,6 +522,7 @@ const CommentBoard = ({
516
522
  }) => {
517
523
  const [actionState, setActionState] = useState(false);
518
524
  const [showConfirmDialog, setShowConfirmDialog] = useState(false);
525
+ const actionButtonRef = useRef(null);
519
526
  const handleConfirmDelete = () => {
520
527
  onDelete(thread);
521
528
  setActionState(false);
@@ -524,6 +531,7 @@ const CommentBoard = ({
524
531
  const handleCancel = () => {
525
532
  setActionState(false);
526
533
  setShowConfirmDialog(false);
534
+ actionButtonRef.current?.focus();
527
535
  };
528
536
  const isResolutionComment = thread.type === "note" && thread.meta && (thread.meta._wp_note_status === "resolved" || thread.meta._wp_note_status === "reopen");
529
537
  const actions = [
@@ -555,131 +563,140 @@ const CommentBoard = ({
555
563
  ];
556
564
  const canResolve = thread.parent === 0;
557
565
  const moreActions = parent?.status !== "approved" ? actions.filter((item) => item.isEligible(thread)) : [];
558
- return /* @__PURE__ */ jsxs(VStack, { spacing: "2", children: [
559
- /* @__PURE__ */ jsxs(HStack, { alignment: "left", spacing: "3", justify: "flex-start", children: [
560
- /* @__PURE__ */ jsx(
561
- CommentAuthorInfo,
562
- {
563
- avatar: thread?.author_avatar_urls?.[48],
564
- name: thread?.author_name,
565
- date: thread?.date,
566
- userId: thread?.author
567
- }
568
- ),
569
- isExpanded && /* @__PURE__ */ jsx(
570
- FlexItem,
571
- {
572
- className: "editor-collab-sidebar-panel__comment-status",
573
- onClick: (event) => {
574
- event.stopPropagation();
575
- },
576
- children: /* @__PURE__ */ jsxs(HStack, { spacing: "0", children: [
577
- canResolve && /* @__PURE__ */ jsx(
578
- Button,
579
- {
580
- label: _x(
581
- "Resolve",
582
- "Mark note as resolved"
566
+ return /* @__PURE__ */ jsxs(
567
+ VStack,
568
+ {
569
+ spacing: "2",
570
+ role: thread.parent !== 0 ? "treeitem" : void 0,
571
+ children: [
572
+ /* @__PURE__ */ jsxs(HStack, { alignment: "left", spacing: "3", justify: "flex-start", children: [
573
+ /* @__PURE__ */ jsx(
574
+ CommentAuthorInfo,
575
+ {
576
+ avatar: thread?.author_avatar_urls?.[48],
577
+ name: thread?.author_name,
578
+ date: thread?.date,
579
+ userId: thread?.author
580
+ }
581
+ ),
582
+ isExpanded && /* @__PURE__ */ jsx(
583
+ FlexItem,
584
+ {
585
+ className: "editor-collab-sidebar-panel__comment-status",
586
+ onClick: (event) => {
587
+ event.stopPropagation();
588
+ },
589
+ children: /* @__PURE__ */ jsxs(HStack, { spacing: "0", children: [
590
+ canResolve && /* @__PURE__ */ jsx(
591
+ Button,
592
+ {
593
+ label: _x(
594
+ "Resolve",
595
+ "Mark note as resolved"
596
+ ),
597
+ size: "small",
598
+ icon: published,
599
+ disabled: thread.status === "approved",
600
+ accessibleWhenDisabled: thread.status === "approved",
601
+ onClick: () => {
602
+ onEdit({
603
+ id: thread.id,
604
+ status: "approved"
605
+ });
606
+ }
607
+ }
583
608
  ),
584
- size: "small",
585
- icon: published,
586
- disabled: thread.status === "approved",
587
- accessibleWhenDisabled: thread.status === "approved",
588
- onClick: () => {
589
- onEdit({
590
- id: thread.id,
591
- status: "approved"
592
- });
593
- }
594
- }
595
- ),
596
- /* @__PURE__ */ jsxs(Menu, { placement: "bottom-end", children: [
597
- /* @__PURE__ */ jsx(
598
- Menu.TriggerButton,
599
- {
600
- render: /* @__PURE__ */ jsx(
601
- Button,
609
+ /* @__PURE__ */ jsxs(Menu, { placement: "bottom-end", children: [
610
+ /* @__PURE__ */ jsx(
611
+ Menu.TriggerButton,
602
612
  {
603
- size: "small",
604
- icon: moreVertical,
605
- label: __("Actions"),
606
- disabled: !moreActions.length,
607
- accessibleWhenDisabled: true
613
+ render: /* @__PURE__ */ jsx(
614
+ Button,
615
+ {
616
+ ref: actionButtonRef,
617
+ size: "small",
618
+ icon: moreVertical,
619
+ label: __("Actions"),
620
+ disabled: !moreActions.length,
621
+ accessibleWhenDisabled: true
622
+ }
623
+ )
608
624
  }
609
- )
610
- }
611
- ),
612
- /* @__PURE__ */ jsx(Menu.Popover, { children: moreActions.map((action) => /* @__PURE__ */ jsx(
613
- Menu.Item,
614
- {
615
- onClick: () => action.onClick(),
616
- children: /* @__PURE__ */ jsx(Menu.ItemLabel, { children: action.title })
617
- },
618
- action.id
619
- )) })
620
- ] })
621
- ] })
622
- }
623
- )
624
- ] }),
625
- "edit" === actionState ? /* @__PURE__ */ jsx(
626
- CommentForm,
627
- {
628
- onSubmit: (value) => {
629
- onEdit({
630
- id: thread.id,
631
- content: value
632
- });
633
- setActionState(false);
634
- },
635
- onCancel: () => handleCancel(),
636
- thread,
637
- submitButtonText: _x("Update", "verb"),
638
- labelText: sprintf(
639
- // translators: %1$s: note identifier, %2$s: author name.
640
- __("Edit note %1$s by %2$s"),
641
- thread.id,
642
- thread.author_name
643
- ),
644
- reflowComments
645
- }
646
- ) : /* @__PURE__ */ jsx(
647
- RawHTML,
648
- {
649
- className: clsx(
650
- "editor-collab-sidebar-panel__user-comment",
625
+ ),
626
+ /* @__PURE__ */ jsx(Menu.Popover, { children: moreActions.map((action) => /* @__PURE__ */ jsx(
627
+ Menu.Item,
628
+ {
629
+ onClick: () => action.onClick(),
630
+ children: /* @__PURE__ */ jsx(Menu.ItemLabel, { children: action.title })
631
+ },
632
+ action.id
633
+ )) })
634
+ ] })
635
+ ] })
636
+ }
637
+ )
638
+ ] }),
639
+ "edit" === actionState ? /* @__PURE__ */ jsx(
640
+ CommentForm,
641
+ {
642
+ onSubmit: (value) => {
643
+ onEdit({
644
+ id: thread.id,
645
+ content: value
646
+ });
647
+ setActionState(false);
648
+ actionButtonRef.current?.focus();
649
+ },
650
+ onCancel: () => handleCancel(),
651
+ thread,
652
+ submitButtonText: _x("Update", "verb"),
653
+ labelText: sprintf(
654
+ // translators: %1$s: note identifier, %2$s: author name.
655
+ __("Edit note %1$s by %2$s"),
656
+ thread.id,
657
+ thread.author_name
658
+ ),
659
+ reflowComments
660
+ }
661
+ ) : /* @__PURE__ */ jsx(
662
+ RawHTML,
651
663
  {
652
- "editor-collab-sidebar-panel__resolution-text": isResolutionComment
664
+ className: clsx(
665
+ "editor-collab-sidebar-panel__user-comment",
666
+ {
667
+ "editor-collab-sidebar-panel__resolution-text": isResolutionComment
668
+ }
669
+ ),
670
+ children: isResolutionComment ? (() => {
671
+ const actionText = thread.meta._wp_note_status === "resolved" ? __("Marked as resolved") : __("Reopened");
672
+ const content = thread?.content?.raw;
673
+ if (content && typeof content === "string" && content.trim() !== "") {
674
+ return sprintf(
675
+ // translators: %1$s: action label ("Marked as resolved" or "Reopened"); %2$s: note text.
676
+ __("%1$s: %2$s"),
677
+ actionText,
678
+ content
679
+ );
680
+ }
681
+ return actionText;
682
+ })() : thread?.content?.rendered
653
683
  }
654
684
  ),
655
- children: isResolutionComment ? (() => {
656
- const actionText = thread.meta._wp_note_status === "resolved" ? __("Marked as resolved") : __("Reopened");
657
- const content = thread?.content?.raw;
658
- if (content && typeof content === "string" && content.trim() !== "") {
659
- return sprintf(
660
- // translators: %1$s: action label ("Marked as resolved" or "Reopened"); %2$s: note text.
661
- __("%1$s: %2$s"),
662
- actionText,
663
- content
664
- );
685
+ "delete" === actionState && /* @__PURE__ */ jsx(
686
+ ConfirmDialog,
687
+ {
688
+ isOpen: showConfirmDialog,
689
+ onConfirm: handleConfirmDelete,
690
+ onCancel: handleCancel,
691
+ confirmButtonText: __("Delete"),
692
+ children: __(
693
+ "Are you sure you want to delete this note? This will also delete all of this note's replies."
694
+ )
665
695
  }
666
- return actionText;
667
- })() : thread?.content?.rendered
668
- }
669
- ),
670
- "delete" === actionState && /* @__PURE__ */ jsx(
671
- ConfirmDialog,
672
- {
673
- isOpen: showConfirmDialog,
674
- onConfirm: handleConfirmDelete,
675
- onCancel: handleCancel,
676
- confirmButtonText: __("Delete"),
677
- children: __(
678
- "Are you sure you want to delete this note? This will also delete all of this note's replies."
679
696
  )
680
- }
681
- )
682
- ] });
697
+ ]
698
+ }
699
+ );
683
700
  };
684
701
  var comments_default = Comments;
685
702
  export {