-
Notifications
You must be signed in to change notification settings - Fork 328
Add double-click inline thread name editing #1453
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
SawyerHood
merged 2 commits into
main
from
bb/enable-inline-thread-name-editing-thr_vpyw5g5dsy
Aug 13, 2026
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
121 changes: 121 additions & 0 deletions
121
apps/app/src/components/thread/InlineThreadTitle.test.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,121 @@ | ||
| // @vitest-environment jsdom | ||
|
|
||
| import { cleanup, fireEvent, render, screen } from "@testing-library/react"; | ||
| import { afterEach, describe, expect, it, vi } from "vitest"; | ||
| import { | ||
| resolveInlineThreadTitleCommit, | ||
| useInlineThreadTitle, | ||
| } from "./InlineThreadTitle"; | ||
|
|
||
| afterEach(() => { | ||
| cleanup(); | ||
| }); | ||
|
|
||
| function InlineTitleHarness({ | ||
| onCommit, | ||
| resetKey = "thr_test", | ||
| title, | ||
| }: { | ||
| onCommit: (nextTitle: string) => void; | ||
| resetKey?: string; | ||
| title: string; | ||
| }) { | ||
| const { editor, isEditing, startEditing } = useInlineThreadTitle({ | ||
| onCommit, | ||
| resetKey, | ||
| title, | ||
| }); | ||
|
|
||
| return ( | ||
| <div> | ||
| {isEditing ? ( | ||
| editor | ||
| ) : ( | ||
| <button type="button" onDoubleClick={startEditing}> | ||
| {title} | ||
| </button> | ||
| )} | ||
| </div> | ||
| ); | ||
| } | ||
|
|
||
| describe("resolveInlineThreadTitleCommit", () => { | ||
| it("commits a trimmed new title", () => { | ||
| expect( | ||
| resolveInlineThreadTitleCommit({ | ||
| currentTitle: "Old name", | ||
| nextTitle: " New name ", | ||
| }), | ||
| ).toEqual({ kind: "commit", title: "New name" }); | ||
| }); | ||
|
|
||
| it("cancels an empty or unchanged title", () => { | ||
| expect( | ||
| resolveInlineThreadTitleCommit({ | ||
| currentTitle: "Same name", | ||
| nextTitle: " ", | ||
| }), | ||
| ).toEqual({ kind: "cancel" }); | ||
| expect( | ||
| resolveInlineThreadTitleCommit({ | ||
| currentTitle: "Same name", | ||
| nextTitle: " Same name ", | ||
| }), | ||
| ).toEqual({ kind: "cancel" }); | ||
| }); | ||
| }); | ||
|
|
||
| describe("useInlineThreadTitle", () => { | ||
| it("commits a changed title on blur and ignores a second close", () => { | ||
| const onCommit = vi.fn(); | ||
| render(<InlineTitleHarness onCommit={onCommit} title="Old name" />); | ||
|
|
||
| fireEvent.doubleClick(screen.getByRole("button", { name: "Old name" })); | ||
| const input = screen.getByRole("textbox", { name: "Thread name" }); | ||
| fireEvent.change(input, { target: { value: "New name" } }); | ||
| fireEvent.keyDown(input, { key: "Enter" }); | ||
| fireEvent.blur(input); | ||
|
|
||
| expect(onCommit).toHaveBeenCalledTimes(1); | ||
| expect(onCommit).toHaveBeenCalledWith("New name"); | ||
| }); | ||
|
|
||
| it("does not commit when the draft is empty", () => { | ||
| const onCommit = vi.fn(); | ||
| render(<InlineTitleHarness onCommit={onCommit} title="Old name" />); | ||
|
|
||
| fireEvent.doubleClick(screen.getByRole("button", { name: "Old name" })); | ||
| const input = screen.getByRole("textbox", { name: "Thread name" }); | ||
| fireEvent.change(input, { target: { value: " " } }); | ||
| fireEvent.blur(input); | ||
|
|
||
| expect(onCommit).not.toHaveBeenCalled(); | ||
| expect(screen.getByRole("button", { name: "Old name" })).not.toBeNull(); | ||
| }); | ||
|
|
||
| it("cancels an open edit when the thread identity changes", () => { | ||
| const firstCommit = vi.fn(); | ||
| const secondCommit = vi.fn(); | ||
| const { rerender } = render( | ||
| <InlineTitleHarness onCommit={firstCommit} title="Old name" />, | ||
| ); | ||
|
|
||
| fireEvent.doubleClick(screen.getByRole("button", { name: "Old name" })); | ||
| fireEvent.change(screen.getByRole("textbox", { name: "Thread name" }), { | ||
| target: { value: "Draft name" }, | ||
| }); | ||
|
|
||
| rerender( | ||
| <InlineTitleHarness | ||
| onCommit={secondCommit} | ||
| resetKey="thr_other" | ||
| title="Other thread" | ||
| />, | ||
| ); | ||
|
|
||
| expect(screen.queryByRole("textbox", { name: "Thread name" })).toBeNull(); | ||
| expect(screen.getByRole("button", { name: "Other thread" })).not.toBeNull(); | ||
| expect(firstCommit).not.toHaveBeenCalled(); | ||
| expect(secondCommit).not.toHaveBeenCalled(); | ||
| }); | ||
| }); |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚨
slopcop/review— The sidebar double-click does not open the editor.A browser sends two
clickevents beforedblclick. The first click follows this link and removes the row. Therefore, this handler never starts the editor. I reproduced this behavior in Chromium against the development app. Please keep the first click on the current route until the double-click decision completes. Please add a browser-level test, or a test that sends the real click sequence.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed. A module-level click mark now survives a remount so the second click still opens the editor.