Skip to content

fix(web): return focus to Edit comment when cancelling a timeline or review comment edit - #47461

Closed
only21mil wants to merge 2 commits into
pingdotgg:mainfrom
only21mil:fix/web-pr-comment-edit-cancel-returns-focus
Closed

only21mil wants to merge 2 commits into
pingdotgg:mainfrom
only21mil:fix/web-pr-comment-edit-cancel-returns-focus

Conversation

@only21mil

Copy link
Copy Markdown
Contributor

Problem

When a keyboard user opens Edit comment in the PR Timeline tab or on a Code tab review thread and cancels with Escape or Cancel, focus lands on another timeline control or the Code pane instead of Edit comment.

Change

ConversationCard (Timeline) and ReviewThreadCard (Code tab) now close the editor with flushSync and focus that comment's Edit comment button, as PullRequestTitleEditor does. ReviewThreadCard keeps one button ref per comment, so a multi-comment thread focuses the right one. Save and the reply box are untouched.

Scope

Small bug fix (keyboard focus lost), no issue. Two production files (26 lines, size:S) and their tests; no new copy.

Verification

Setup. Ubuntu 26.04, headless Chromium (1280×820), light theme, empty dev server on each commit, PR sample/sample-repo#1 on a local Forgejo server (the app shows Edit comment only on the viewer's own comments); input sent through the debugging port (Playwright).
Steps (Linux). Open PR #1 → Timeline → expand 2 comments → Edit comment → Enter → Escape (repeat via Tab to Cancel → Enter); Code → expand notes.md → Edit comment → Enter → Escape (repeat via Cancel).

141853b (base) edb23e5 (fix)
Timeline Escape jumps to reaction
Timeline Escape jumps to reaction
Timeline Escape focuses Edit comment
Timeline Escape focuses Edit comment
Review Escape drops to Code pane
Review Escape drops to Code pane
Review Escape focuses Edit comment
Review Escape focuses Edit comment
Cancel button captures (Timeline and Code)
141853b (base) edb23e5 (fix)
Timeline Cancel jumps to notes.md:3
Timeline Cancel jumps to notes.md:3
Timeline Cancel focuses Edit comment
Timeline Cancel focuses Edit comment
Review Cancel drops to Code pane
Review Cancel drops to Code pane
Review Cancel focuses Edit comment
Review Cancel focuses Edit comment

Both browser tests (Escape, including a two-comment review thread) fail on 141853b and pass on edb23e5 and on edb23e5 merged with main 43dc7dd; vp run check:changed passes. Pointer Cancel returns focus without :focus-visible. An AI agent ran every check.

Not shown. Desktop (same web bundle), mobile (PullRequestEditScreen), video (no motion/timing).

Generated with Gemini 4 Neon in T3 Code Nightly

@github-actions github-actions Bot added vouch:unvouched Author is not yet trusted in the VOUCHED list. size:S 10-29 changed lines (additions + deletions). labels Dec 2, 2026
@macroscopeapp

macroscopeapp Bot commented Dec 2, 2026

Copy link
Copy Markdown
Contributor

Approvability

Verdict: Approved at edb23e5

Macroscope's review found this PR approvable — Cancelling a timeline or review comment edit now returns focus to its Edit comment button without scrolling. The change is limited to local UI focus handling and leaves saving and permissions unchanged.

You can add or adjust custom eligibility rules. Learn more.

@coderabbitai

coderabbitai Bot commented Dec 2, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

Important

Review skipped

Review was skipped as selected files did not have any reviewable changes.

Run configuration

Commits

Reviewing files that changed from the base of the PR and between edb23e5 and 36b318a.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review

No actionable comments were generated in the recent review.

Walkthrough

When a user cancels editing a pull request comment, both comment interfaces now clear the edit state and restore focus to that comment’s Edit button. Browser tests cover Escape cancellation and focus restoration.

Changes: Edit cancellation focus restoration

Layer / File(s) Summary
Cancel editing and restore focus
apps/web/src/components/pullRequest/PullRequestReviewAnnotation.tsx, apps/web/src/components/pullRequest/PullRequestReviewAnnotation.browser.test.tsx, apps/web/src/components/pullRequest/PullRequestTimelineTab.tsx, apps/web/src/components/pullRequest/PullRequestTimelineTab.browser.test.tsx
Both comment interfaces synchronously clear editing state and restore focus to the relevant Edit button without scrolling. Browser tests verify that Escape closes the editor and restores focus.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Suggested reviewers: chenxin-yan

Merge Risk: Minimal · previous review edb23

This change returns keyboard focus to the correct Edit button after a user cancels a comment edit. It is a small UI change with test coverage for Escape, and no merge-blocking risk was found.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title follows the conventional commit format and names the main change: focus returns to the Edit comment button when a timeline or review comment edit is cancelled. The raw summary confirms the c…
Description check Passed The description follows the template. It has Problem, Change, Scope, and Verification sections. It explains the keyboard focus bug and the flushSync and ref fix. It justifies the lack of an issue as a…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title follows the conventional commit format and names the main change: focus returns to the Edit comment button when a timeline or review comment edit is cancelled. The raw summary confirms the changes to ConversationCard and ReviewThreadCard do exactly this.

Full details: Description check

Explanation

The description follows the template. It has Problem, Change, Scope, and Verification sections. It explains the keyboard focus bug and the flushSync and ref fix. It justifies the lack of an issue as a small obvious bug fix. Verification lists the setup, steps, before and after screenshots, and test results, and it states what was not checked (desktop, mobile, video). The template's optional agent-model line is present (Gemini 4 Neon). A minor gap is that the Scope section does not link an issue, but the author gives a reason for omitting one.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 756baf8 and edb23e5.

Files selected for processing: 4

  • apps/web/src/components/pullRequest/PullRequestReviewAnnotation.browser.test.tsx
  • apps/web/src/components/pullRequest/PullRequestReviewAnnotation.tsx
  • apps/web/src/components/pullRequest/PullRequestTimelineTab.browser.test.tsx
  • apps/web/src/components/pullRequest/PullRequestTimelineTab.tsx

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.

@juliusmarminge juliusmarminge added the takeover:in-progress A takeover lead is working on this PR label Dec 2, 2026
@juliusmarminge juliusmarminge added takeover:needs-julius Takeover done; route gate says Julius decides and removed takeover:in-progress A takeover lead is working on this PR labels Dec 2, 2026
@only21mil only21mil closed this Dec 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:S 10-29 changed lines (additions + deletions). takeover:needs-julius Takeover done; route gate says Julius decides vouch:unvouched Author is not yet trusted in the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants