Skip to content

fix(CommentComposer): the caller's onClick runs, and a click bubbles outside a thread - #13738

Open
ernestt wants to merge 1 commit into
fix/comments-resolve-focusfrom
fix/comment-composer-onclick
Open

ernestt wants to merge 1 commit into
fix/comments-resolve-focusfrom
fix/comment-composer-onclick

Conversation

@ernestt

@ernestt ernestt commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

Stacked on #13737 (the previous Comments fix) only so the Comments move includes it. It touches none of CommentPin's files and applies cleanly to main (2608fe4) on its own.

User impact

A product that passes onClick to a standalone CommentComposer, for example to track a press or open a panel, never sees it run. Clicks inside a standalone composer also never reach its ancestors, so a host's own click handling around it breaks.

Problem and solution fit

  1. Why does onClick never run? The composer set its own root onClick after spreading the caller's props, so its handler replaced the caller's.
  2. Why do clicks not bubble? That handler stopped propagation on every click. Only a composer inside a thread needs that, so a press in its empty space does not toggle the thread.
  3. Why does it matter? architecture:public-component-api promises that a component forwards neutral DOM event props. A silently dropped handler is hard to find.

The composer now calls the caller's onClick first. It stops propagation only inside a thread (a reply or an edit), where the thread would otherwise close.

Expected behavior and authority

  • architecture:public-component-api: the root forwards neutral DOM and event props, and component-owned behavior composes with them instead of replacing them.
  • Component audit rubric BLOCK P3 (graduation issue list): the composer drops the caller's onClick and stops every click. It was confirmed in the source on main.

Smallest restoration

CommentComposer takes the caller's onClick out of the root props, calls it from its own handler, and stops propagation only when its context is a reply or an edit. No API, visual, or other behavior change.

Evidence

  • Reproduction before the change: a test renders a standalone composer with onClick inside a parent with onClick, and presses the composer. Neither handler runs.
  • Result after the change: both run.
  • Representative unchanged path: a press in the empty space of a thread's reply composer keeps the thread open ("stays open on a press in the empty space of its reply composer").
  • Regression tests: CommentComposer.test.tsx "calls the caller's onClick and lets the click bubble" (fails without the fix) and the thread case in CommentThread.test.tsx.

This is event wiring with no layout or pixel effect, so there are no screenshots.

Scope

Components: CommentComposer

  • One defect is restored.
  • Separable contradictory or unsettled tagalongs were removed or split.
  • No new public API, visual representation, default, or interaction model is hidden under the bug-fix label.
  • Public text and artifacts contain no internal Meta context.

Testing

  • vitest run packages/lab/src/Comments: pass. The new composer case fails without the fix.

  • pnpm review:pre: 0 findings. prettier and eslint on the changed files: clean.

  • Rebased onto main at 2608fe4, with no change to its own diff (the same patch ID as before the rebase). Repeated on this head: vitest run packages/lab/src/Comments: 101 passed. pnpm review:pre: 0 findings.

@vercel

vercel Bot commented Nov 24, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
astryx Ready Ready Preview Dec 2, 2026 5:15am UTC

Request Review

@astracat-bot

astracat-bot Bot commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

AI review status for this pull request.

Review status Updated
🟢 Reviewed (for maintainers only) Dec 2, 2026, 5:12 AM UTC

@astracat-bot astracat-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved pending CI: CI has not run on this head yet. It runs only for pull requests into main, so it runs once this pull request targets main.

No blocking findings. One optional suggestion:

  • CommentComposer.tsx:593 runs the caller's onClick before the composer focuses its input. A caller that moves focus synchronously loses it on a press in the composer's empty space. Consider calling it after the focus step, or documenting the order and pinning it in the new test.
Claims and files checked

Review mode: full; reason: no-earlier-review

  • Claim: stacked on the previous Comments fix and touches none of CommentPin's files: verified, all three files are under packages/lab/src/Comments.
  • Claim: applies cleanly to main: verified with a clean three-way merge onto main.
  • Claim: a standalone composer's onClick never ran and its clicks never reached ancestors: verified, the composer set its own onClick after the spread and always stopped propagation.
  • Claim: the composer now calls the caller's onClick first and stops propagation only for a reply or an edit: verified at CommentComposer.tsx:571-598.
  • Claim: the public component API record promises that event props reach the root: verified.
  • Claim: the defect exists on main: verified, the file on main matches the base.
  • Claim: no API, visual or other behavior change: verified. The only behavior change is the one the title names, and it also covers the Comments panel's new-comment composer.
  • Claim: the new composer test fails without the fix and passes with it, and the thread test keeps a reply composer's empty-space press from closing the thread: verified by reading both tests against the base and head code.
  • Claim: the Comments tests, the pre-review checklist, Prettier and ESLint pass: left to CI, not reproduced in this review.
  • Claim: rebased onto main at the stated commit: verified.
  • File CommentComposer.tsx: one optional suggestion (above); otherwise clear.
  • File CommentComposer.test.tsx: clear.
  • File CommentThread.test.tsx: clear.

Automated review (maintainer link)

// The composer keeps its clicks: in a thread, a press on its empty
// space would otherwise reach the thread and collapse it.
event.stopPropagation();
onRootClick?.(event);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Optional: the caller's handler runs before the composer's own work, and it cannot cancel that work. So a caller that moves focus synchronously here, for example into a panel it opens, loses that focus: on a press in the composer's empty space, the composer then focuses its input. Consider calling onRootClick?.(event) after the focus step, or documenting the order on onClick and pinning it in the new test.

@ernestt
ernestt force-pushed the fix/comments-resolve-focus branch from a72ff8b to f90cbbd Compare November 24, 2026 18:45
@ernestt
ernestt force-pushed the fix/comment-composer-onclick branch from 26286ae to 6fb0bbf Compare November 24, 2026 18:45

@astracat-bot astracat-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved pending CI: CI has not run on this head yet. It runs only for pull requests into main, so it runs once this pull request targets main.

No blocking findings. One optional suggestion:

  • CommentComposer.tsx:593 runs the caller's onClick before the composer focuses its input. A caller that moves focus synchronously loses it on a press in the composer's empty space. Consider calling it after the focus step, or documenting the order and pinning it in the new test.
Claims and files checked

Review mode: carry-forward; reason: none

  • Claim: stacked on the previous Comments fix and touches none of CommentPin's files: verified, all three files are under packages/lab/src/Comments.
  • Claim: applies cleanly to main: verified with a clean three-way merge onto main.
  • Claim: a standalone composer's onClick never ran and its clicks never reached ancestors: verified, the composer set its own onClick after the spread and always stopped propagation.
  • Claim: the composer now calls the caller's onClick first and stops propagation only for a reply or an edit: verified at CommentComposer.tsx:571-598.
  • Claim: the public component API record promises that event props reach the root: verified.
  • Claim: the defect exists on main: verified, the file on main matches the base.
  • Claim: no API, visual or other behavior change: verified. The only behavior change is the one the title names, and it also covers the Comments panel's new-comment composer.
  • Claim: the new composer test fails without the fix and passes with it, and the thread test keeps a reply composer's empty-space press from closing the thread: verified by reading both tests against the base and head code.
  • Claim: the Comments tests, the pre-review checklist, Prettier and ESLint pass: left to CI, not reproduced in this review.
  • Claim: validated on main and rebased onto main at the stated commits: verified, both commits are on main and the second is this branch's merge base with main.
  • File CommentComposer.tsx: one optional suggestion (above); otherwise clear.
  • File CommentComposer.test.tsx: clear.
  • File CommentThread.test.tsx: clear.

Automated review (maintainer link)

@astracat-bot astracat-bot Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved pending CI: CI has not run on this head yet. It runs only for pull requests into main, so it runs once this pull request targets main.

No blocking findings. One optional suggestion:

  • CommentComposer.tsx:593 runs the caller's onClick before the composer focuses its input, so a caller that moves focus synchronously loses it on a press in the composer's empty space (reproduced locally). Consider composeEventHandlers(handleRootClick, onRootClick) so the composer runs first, or documenting the order and pinning it in the new test.
Claims and files checked

Review mode: full; reason: recipe-changed (many rules)

  • Title, the caller's onClick runs: verified, reproduced locally. The new test and extra clicks on the input, an enabled Post and the emoji button each call it once, and none did before.
  • Title, a click bubbles outside a thread: verified, reproduced locally. The same clicks now reach an ancestor handler, while reply and edit composers still stop them.
  • Stacked on the previous Comments fix and touches none of CommentPin's files: verified. All three files are under packages/lab/src/Comments.
  • Applies cleanly to main: verified. This pull request's own change merges onto current main without conflicts.
  • Before the fix, a standalone composer's onClick never ran and its clicks never reached ancestors: verified. The composer set its own onClick after the spread and always stopped propagation, and the new test fails against the old component.
  • Only a composer inside a thread needs the stop: verified. Of the four composer call sites, only the reply and edit composers sit inside a clickable thread surface.
  • The composer now calls the caller's onClick first and stops propagation only for a reply or an edit: verified at CommentComposer.tsx:571-598. The context type has exactly those three kinds.
  • The public component API record promises that event props reach the root and that built-in behavior composes with them: verified against its forwarding and handler-composition clauses.
  • A component audit item flags this defect on main: the defect is on main, where the file matches this branch's base. The audit list itself is not in the repository, so this is reported.
  • No API, visual or other behavior change: verified. The only behavior change is the one the title names, and it also covers the Comments panel's new-comment composer.
  • The new composer test fails without the fix, and the thread test keeps a reply composer's empty-space press from closing the thread: verified, reproduced locally. The thread test also fails once the thread stop is removed.
  • Event wiring with no layout or pixel effect: verified. The change touches no markup or style.
  • Scope checklist (one defect, no tagalongs, no hidden API or interaction change, no internal context): verified.
  • The Comments tests pass: verified, reproduced locally.
  • The pre-review checklist, Prettier and ESLint are clean: reported. Locally, Prettier passes, and ESLint shows no errors and one existing warning on an unchanged line.
  • Validated on main and rebased onto main at the stated commits: verified. Both commits are on main, and the second is this branch's merge base with main.
  • File CommentComposer.tsx: one optional suggestion (above); otherwise clear.
  • File CommentComposer.test.tsx: clear.
  • File CommentThread.test.tsx: clear.

Automated review (maintainer link)

…outside a thread

CommentComposer set its own root onClick after the caller's props, so a
caller's `onClick` never ran, and it stopped every click from bubbling. The
caller's handler now runs first. Only a reply or edit composer inside a
thread stops the click, so a press on its empty space does not collapse the
thread.
@ernestt

ernestt commented Dec 2, 2026

Copy link
Copy Markdown
Contributor Author

Rebased onto main at 2608fe4 with the rest of the stack. This pull request's own diff is unchanged: its patch ID is the same as before the rebase, and it applied without conflicts. In the stack, only #13737 changed in content; #13702, #13735, #13736, #13738, #13739, #13740 and #13741 are unchanged apart from the rebase.

Repeated on this head: vitest run packages/lab/src/Comments: 101 passed. pnpm review:pre: 0 findings. It still applies cleanly to main on its own.

@astracat-bot astracat-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved pending CI: CI has not run on this head yet. It runs only for pull requests into main, so it runs once this pull request targets main.

No blocking findings. One optional suggestion:

  • CommentComposer.tsx:593 runs the caller's onClick before the composer focuses its input, so a caller that moves focus synchronously loses it on a press in the composer's empty space (reproduced locally). Consider composeEventHandlers(handleRootClick, onRootClick) so the composer runs first, or documenting the order and pinning it in the new test.
Claims and files checked

Review mode: carry-forward; reason: none

  • Title, the caller's onClick runs: verified, reproduced locally. The new test and extra clicks on the input, an enabled Post and the emoji button each call it once on this head, and none did on the base.
  • Title, a click bubbles outside a thread: verified, reproduced locally. The same clicks now reach an ancestor handler, while reply and edit composers still stop them.
  • Stacked on the previous Comments fix and touches none of CommentPin's files: verified. The base branch is that fix's branch, and all three files are under packages/lab/src/Comments.
  • Applies cleanly to main on its own: verified. This pull request's own commit merges without conflicts onto the stated main commit and onto current main.
  • Rebased onto main with no change to its own diff: verified. Its patch is byte-identical to the one reviewed before the rebase, with the same patch ID.
  • Before the fix, a standalone composer's onClick never ran and its clicks never reached ancestors: verified. The composer set its own onClick after the spread and always stopped propagation, and the new test fails against the old component (reproduced locally).
  • Only a composer inside a thread needs the stop: verified. Of the four composer call sites, only the reply and edit composers sit inside a clickable thread surface.
  • The composer now calls the caller's onClick first and stops propagation only for a reply or an edit: verified at CommentComposer.tsx:571-598. The context type has exactly those three kinds.
  • The public component API record promises that event props reach the root and that built-in behavior composes with them: verified against its forwarding and handler-composition clauses.
  • A component audit item flags this defect on main: the defect is on main, where the file matches this branch's base. The audit list itself is not in the repository, so this is reported.
  • No API, visual or other behavior change: verified. The only behavior change is the one the title names, and it also covers the Comments panel's new-comment composer.
  • The new composer test fails without the fix, and the thread test keeps a reply composer's empty-space press from closing the thread: verified, reproduced locally. The thread test also fails once the thread stop is removed.
  • Event wiring with no layout or pixel effect: verified. The change touches no markup or style.
  • Scope checklist (one defect, no tagalongs, no hidden API or interaction change, no internal context): verified.
  • The Comments tests pass, 101 of them on this head: verified, reproduced locally (4 files, 101 passed).
  • The pre-review report shows 0 findings: verified, reproduced locally.
  • Prettier and ESLint are clean on the changed files: reported. Locally, Prettier passes, and ESLint shows no errors and one existing warning on an unchanged line.
  • File CommentComposer.tsx: one optional suggestion (above); otherwise clear.
  • File CommentComposer.test.tsx: clear.
  • File CommentThread.test.tsx: clear.

Automated review (maintainer link)

This branch was successfully deployed

1 active deployment
Preview — e026f57d Deployed Dec 2, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Meta Open Source bot.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant