@@ -97,7 +97,21 @@ export function ChannelThread(props: ThreadProps) {
9797 ) ;
9898
9999 const isThreadFocused = ( ) => ! ! replySelection . selectedId ( ) ;
100+
101+ // Channel navigation landed on this root message (and not on one of its
102+ // replies).
103+ const isRootNavTargeted = ( ) =>
104+ ! ! props . targetThreadId &&
105+ props . targetThreadId === props . data ( ) . id &&
106+ ! props . activeTargetReplyId ;
107+
100108 const selectThreadMessage = ( ) => {
109+ // Clicking the navigation-targeted message releases the target instead
110+ // of toggling selection.
111+ if ( isRootNavTargeted ( ) ) {
112+ props . onClearTarget ?.( props . data ( ) . id ) ;
113+ return ;
114+ }
101115 // On touch devices, we want to block "click to select"
102116 if ( isTouchDevice ( ) ) return ;
103117 if ( isSelected ( ) && ! isThreadFocused ( ) ) {
@@ -110,6 +124,12 @@ export function ChannelThread(props: ThreadProps) {
110124 } ;
111125
112126 const selectReply = ( replyId : string ) => {
127+ // Clicking the navigation-targeted reply releases the target instead of
128+ // toggling selection.
129+ if ( props . activeTargetReplyId === replyId ) {
130+ props . onClearTarget ?.( props . data ( ) . id ) ;
131+ return ;
132+ }
113133 // On touch devices, we want to block "click to select"
114134 if ( isTouchDevice ( ) ) return ;
115135 if ( isSelected ( ) && replySelection . selectedId ( ) === replyId ) {
@@ -267,12 +287,8 @@ export function ChannelThread(props: ThreadProps) {
267287 selected = { isSelected ( ) && ! isThreadFocused ( ) }
268288 targeted = {
269289 // The unified input's reply is bound to this root, or
270- // channel navigation landed on it (and not on one of its
271- // replies).
272- unifiedReplyBinding ( ) ?. boundToRoot ||
273- ( ! ! props . targetThreadId &&
274- props . targetThreadId === props . data ( ) . id &&
275- ! props . activeTargetReplyId )
290+ // channel navigation landed on it.
291+ unifiedReplyBinding ( ) ?. boundToRoot || isRootNavTargeted ( )
276292 }
277293 />
278294 </ DebugSuspense >
0 commit comments