Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 24 additions & 16 deletions packages/editor/src/components/collab-sidebar/comments.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,22 +69,29 @@ export function Comments( {
const { selectBlock, toggleBlockSpotlight } = unlock(
useDispatch( blockEditorStore )
);
const { blockCommentId, selectedBlockClientId, orderedBlockIds } =
useSelect( ( select ) => {
const {
getBlockAttributes,
getSelectedBlockClientId,
getClientIdsWithDescendants,
} = select( blockEditorStore );
const clientId = getSelectedBlockClientId();
return {
blockCommentId: clientId
? getBlockAttributes( clientId )?.metadata?.noteId
: null,
selectedBlockClientId: clientId,
orderedBlockIds: getClientIdsWithDescendants(),
};
}, [] );

const {
blockCommentId,
selectedBlockClientId,
orderedBlockIds,
blockMode,
} = useSelect( ( select ) => {
const {
getBlockAttributes,
getSelectedBlockClientId,
getClientIdsWithDescendants,
getBlockMode,
} = select( blockEditorStore );
const clientId = getSelectedBlockClientId();
return {
blockCommentId: clientId
? getBlockAttributes( clientId )?.metadata?.noteId
: null,
selectedBlockClientId: clientId,
orderedBlockIds: getClientIdsWithDescendants(),
blockMode: clientId ? getBlockMode( clientId ) : null,
};
}, [] );

const relatedBlockElement = useBlockElement( selectedBlockClientId );

Expand Down Expand Up @@ -311,6 +318,7 @@ export function Comments( {
threads,
selectedThread,
setCanvasMinHeight,
blockMode,
] );

const handleThreadNavigation = ( event, thread, isSelected ) => {
Expand Down
13 changes: 12 additions & 1 deletion packages/editor/src/components/collab-sidebar/hooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,17 @@ export function useFloatingThread( {
const blockRef = useRef();
useBlockElementRef( thread.blockClientId, blockRef );

const blockMode = useSelect(
( select ) => {
return thread.blockClientId
? select( blockEditorStore ).getBlockMode(
thread.blockClientId
)
: null;
},
[ thread.blockClientId ]
);

const updateHeight = useCallback(
( id, newHeight ) => {
setHeights( ( prev ) => {
Expand Down Expand Up @@ -400,7 +411,7 @@ export function useFloatingThread( {
if ( blockRef.current ) {
refs.setReference( blockRef.current );
}
}, [ blockRef, refs, commentLastUpdated ] );
}, [ blockRef, refs, commentLastUpdated, blockMode ] );

// Track thread heights.
useEffect( () => {
Expand Down
Loading