Skip to content

Commit 3f26cd9

Browse files
author
Evie Gauthier
committed
fix: hide ThreadIndicator badge inside ThreadDrawer compose box
Inside the ThreadDrawer the user is already in thread context, so showing the "Thread" badge in the reply chip is redundant and visually noisy. The compose box always sets replyDraft.relation.rel_type = RelationType.Thread when threadRootId is set (so the message goes to the right thread), but that should not make the ThreadIndicator visible there. Add !threadRootId guard to the ThreadIndicator render condition. Adds 4 unit tests covering the four branches of the condition.
1 parent 9ed985a commit 3f26cd9

2 files changed

Lines changed: 44 additions & 1 deletion

File tree

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
/**
2+
* Tests for the ThreadIndicator visibility condition in the compose strip.
3+
*
4+
* The indicator renders when a user is replying to a thread message from the
5+
* main timeline (no threadRootId). It must NOT appear when composing inside
6+
* the ThreadDrawer (threadRootId is set), because the drawer already makes the
7+
* thread context obvious.
8+
*
9+
* Mirrors the exact render guard in RoomInput.tsx:
10+
* {replyDraft.relation?.rel_type === RelationType.Thread && !threadRootId && (
11+
* <ThreadIndicator />
12+
* )}
13+
*/
14+
import { describe, it, expect } from 'vitest';
15+
import { render, screen } from '@testing-library/react';
16+
import { RelationType } from '$types/matrix-sdk';
17+
import { ThreadIndicator } from './Reply';
18+
19+
function Subject({ relType, threadRootId }: { relType?: string; threadRootId?: string }) {
20+
return <>{relType === RelationType.Thread && !threadRootId && <ThreadIndicator />}</>;
21+
}
22+
23+
describe('ThreadIndicator visibility in compose strip', () => {
24+
it('renders in the main timeline compose box when a thread relation is active', () => {
25+
render(<Subject relType={RelationType.Thread} />);
26+
expect(screen.getByText('Thread')).toBeInTheDocument();
27+
});
28+
29+
it('is hidden inside the ThreadDrawer when threadRootId is set', () => {
30+
render(<Subject relType={RelationType.Thread} threadRootId="$root:example.com" />);
31+
expect(screen.queryByText('Thread')).not.toBeInTheDocument();
32+
});
33+
34+
it('is hidden when the draft has no relation', () => {
35+
render(<Subject relType={undefined} />);
36+
expect(screen.queryByText('Thread')).not.toBeInTheDocument();
37+
});
38+
39+
it('is hidden for a non-thread relation type', () => {
40+
render(<Subject relType="m.in_reply_to" />);
41+
expect(screen.queryByText('Thread')).not.toBeInTheDocument();
42+
});
43+
});

src/app/features/room/RoomInput.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1126,7 +1126,7 @@ export const RoomInput = forwardRef<HTMLDivElement, RoomInputProps>(
11261126
grow="Yes"
11271127
style={{ minWidth: 0 }}
11281128
>
1129-
{replyDraft.relation?.rel_type === RelationType.Thread && (
1129+
{replyDraft.relation?.rel_type === RelationType.Thread && !threadRootId && (
11301130
<ThreadIndicator />
11311131
)}
11321132
<ReplyLayout

0 commit comments

Comments
 (0)