Skip to content

Commit 53a652b

Browse files
authored
Merge pull request #347 from SableClient/fix/thread-indicator
fix: hide ThreadIndicator badge inside ThreadDrawer compose box
2 parents 3d75daf + e1d51ad commit 53a652b

3 files changed

Lines changed: 49 additions & 1 deletion

File tree

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
default: patch
3+
---
4+
5+
Hide the redundant "Thread" indicator badge in the compose box when inside the Thread Drawer.
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
@@ -1154,7 +1154,7 @@ export const RoomInput = forwardRef<HTMLDivElement, RoomInputProps>(
11541154
grow="Yes"
11551155
style={{ minWidth: 0 }}
11561156
>
1157-
{replyDraft.relation?.rel_type === RelationType.Thread && (
1157+
{replyDraft.relation?.rel_type === RelationType.Thread && !threadRootId && (
11581158
<ThreadIndicator />
11591159
)}
11601160
<ReplyLayout

0 commit comments

Comments
 (0)