Prevent thread from being selected when thread menu is focused

This commit is contained in:
Harrison Healey 2025-07-11 16:44:26 -04:00
parent 7e396b1ac0
commit c6a37b60b2
No known key found for this signature in database
GPG key ID: 645A033311E2725E
2 changed files with 19 additions and 4 deletions

View file

@ -130,6 +130,13 @@ function ThreadItem({
return;
}
}
// Don't select the thread when a menu is focused
if (e.target instanceof HTMLElement &&
(e.target.hasAttribute('aria-haspopup') || e.target.role === 'menuitem')) {
return;
}
if (e.altKey) {
const hasUnreads = thread ? Boolean(thread.unread_replies) : false;
const lastViewedAt = hasUnreads ? Date.now() : unreadTimestamp;

View file

@ -126,7 +126,9 @@ function ThreadMenu({
/>
</>)
}
onClick={useCallback(() => {
onClick={useCallback((e: React.MouseEvent | React.KeyboardEvent) => {
e.stopPropagation();
dispatch(setThreadFollow(currentUserId, currentTeamId, threadId, !isFollowing));
readAloud(isFollowing ? formatMessage({
id: 'threading.threadMenu.unfollowed',
@ -144,7 +146,9 @@ function ThreadMenu({
defaultMessage='Open in channel'
/>
}
onClick={useCallback(() => {
onClick={useCallback((e: React.MouseEvent | React.KeyboardEvent) => {
e.stopPropagation();
goToInChannel(threadId);
readAloud(formatMessage({
id: 'threading.threadMenu.openingChannel',
@ -178,7 +182,9 @@ function ThreadMenu({
defaultMessage='Save'
/>
)}
onClick={useCallback(() => {
onClick={useCallback((e: React.MouseEvent | React.KeyboardEvent) => {
e.stopPropagation();
dispatch(isSaved ? unsavePost(threadId) : savePost(threadId));
readAloud(isSaved ? formatMessage({
id: 'threading.threadMenu.unsaved',
@ -196,7 +202,9 @@ function ThreadMenu({
defaultMessage='Copy link'
/>
}
onClick={useCallback(() => {
onClick={useCallback((e: React.MouseEvent | React.KeyboardEvent) => {
e.stopPropagation();
copyToClipboard(`${getSiteURL()}/${team}/pl/${threadId}`);
readAloud(formatMessage({
id: 'threading.threadMenu.linkCopied',