Skip to content

Commit b4045d9

Browse files
committed
Reapply "Notes position alignment in HTML (#73046)"
This reverts commit 8f1076e.
1 parent 8f1076e commit b4045d9

2 files changed

Lines changed: 36 additions & 17 deletions

File tree

packages/editor/src/components/collab-sidebar/comments.js

Lines changed: 24 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -69,22 +69,29 @@ export function Comments( {
6969
const { selectBlock, toggleBlockSpotlight } = unlock(
7070
useDispatch( blockEditorStore )
7171
);
72-
const { blockCommentId, selectedBlockClientId, orderedBlockIds } =
73-
useSelect( ( select ) => {
74-
const {
75-
getBlockAttributes,
76-
getSelectedBlockClientId,
77-
getClientIdsWithDescendants,
78-
} = select( blockEditorStore );
79-
const clientId = getSelectedBlockClientId();
80-
return {
81-
blockCommentId: clientId
82-
? getBlockAttributes( clientId )?.metadata?.noteId
83-
: null,
84-
selectedBlockClientId: clientId,
85-
orderedBlockIds: getClientIdsWithDescendants(),
86-
};
87-
}, [] );
72+
73+
const {
74+
blockCommentId,
75+
selectedBlockClientId,
76+
orderedBlockIds,
77+
blockMode,
78+
} = useSelect( ( select ) => {
79+
const {
80+
getBlockAttributes,
81+
getSelectedBlockClientId,
82+
getClientIdsWithDescendants,
83+
getBlockMode,
84+
} = select( blockEditorStore );
85+
const clientId = getSelectedBlockClientId();
86+
return {
87+
blockCommentId: clientId
88+
? getBlockAttributes( clientId )?.metadata?.noteId
89+
: null,
90+
selectedBlockClientId: clientId,
91+
orderedBlockIds: getClientIdsWithDescendants(),
92+
blockMode: clientId ? getBlockMode( clientId ) : null,
93+
};
94+
}, [] );
8895

8996
const relatedBlockElement = useBlockElement( selectedBlockClientId );
9097

@@ -311,6 +318,7 @@ export function Comments( {
311318
threads,
312319
selectedThread,
313320
setCanvasMinHeight,
321+
blockMode,
314322
] );
315323

316324
const handleThreadNavigation = ( event, thread, isSelected ) => {

packages/editor/src/components/collab-sidebar/hooks.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -372,6 +372,17 @@ export function useFloatingThread( {
372372
const blockRef = useRef();
373373
useBlockElementRef( thread.blockClientId, blockRef );
374374

375+
const blockMode = useSelect(
376+
( select ) => {
377+
return thread.blockClientId
378+
? select( blockEditorStore ).getBlockMode(
379+
thread.blockClientId
380+
)
381+
: null;
382+
},
383+
[ thread.blockClientId ]
384+
);
385+
375386
const updateHeight = useCallback(
376387
( id, newHeight ) => {
377388
setHeights( ( prev ) => {
@@ -400,7 +411,7 @@ export function useFloatingThread( {
400411
if ( blockRef.current ) {
401412
refs.setReference( blockRef.current );
402413
}
403-
}, [ blockRef, refs, commentLastUpdated ] );
414+
}, [ blockRef, refs, commentLastUpdated, blockMode ] );
404415

405416
// Track thread heights.
406417
useEffect( () => {

0 commit comments

Comments
 (0)