Skip to content

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

Open
cixzhang wants to merge 2 commits into
mainfrom
lane2/comment-composer-onclick
Open

cixzhang wants to merge 2 commits into
mainfrom
lane2/comment-composer-onclick

Conversation

@cixzhang

@cixzhang cixzhang commented Dec 1, 2026 •

Copy link
Copy Markdown
Contributor

Cherry-picked from #13738 by @ernestt, who wrote this fix; the commit credits @ernestt with a Co-authored-by line. This team pull request carries it onto current main.

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), as before. For a reply composer, that keeps a press on its empty space from collapsing the thread. A thread is not selectable while an edit is open.

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

  • This head adds one corrected source comment on top of the cherry-pick (CommentComposer.tsx: the stop keeps a reply composer's thread from closing), with no code change.
  • On fix(CommentComposer): the caller's onClick runs, and a click bubbles outside a thread #13738: vitest run packages/lab/src/Comments passed, and the new composer case fails without the fix. pnpm review:pre, prettier and eslint were clean.
  • At 65947eec (a clean cherry-pick onto current main), rerun on Linux:
    • install, build, tsc (core, lab), prettier, eslint and check:changesets all pass;
    • CommentComposer and CommentThread 41/41, twice.

Overlap checked: #13740, #13739, #13738, #13736, #13737, #13735 (separate: #13738 is the original by @ernestt, which this team pull request replaces with the same commit on current main; #13739's replacement is stacked on this one; #13740, #13736, #13737 and #13735 are ernestt's other Comments pull requests, each its own change)

…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.

Cherry-picked from #13738 (by @ernestt).

Co-authored-by: Ernest Tien <ernesttien@meta.com>
@vercel

vercel Bot commented Dec 1, 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 1, 2026 8:03pm UTC

Request Review

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Dec 1, 2026
@astracat-bot

astracat-bot Bot commented Dec 1, 2026 •

Copy link
Copy Markdown
Contributor

AI review status for this pull request.

Review status Updated
🟢 Reviewed (for maintainers only) Dec 1, 2026, 10:53 PM UTC

@github-actions

github-actions Bot commented Dec 1, 2026 •

Copy link
Copy Markdown
Contributor

PR Analysis Report

🔎 Preview · 3db2493

Storybook · Sandbox · built from this PR's head

Modified components

Component Size LoC
lab/CommentThread 385.4 kB (+32 B) · 2.4 kB CSS (0) —
lab/Comments 392.3 kB (+17 B) · 2.5 kB CSS (0) —
lab/CommentComposer 192.3 kB (+12 B) · 1.9 kB CSS (0) —

Package size: no published package changed; no new dependencies.

Not run on this PR: add ci:run-visual for Visual, ci:run-a11y for Accessibility, ci:run-rtl for RTL.


Generated by PR Enrichment workflow | View full report

@cixzhang

cixzhang commented Dec 1, 2026

Copy link
Copy Markdown
Contributor Author

/approve-spec 65947ee

@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.

Requesting changes for two description fixes; from reading the code, the change itself has no defect.

  • The Testing section says this branch is the validated work rebased onto an older main commit, but this head sits on main 255 commits later (including changes to CommentActions.tsx and Comments.test.tsx), so please name the base the reported checks ran on, or rerun them on this head and say so.
  • Miss: the description says the composer stops a click in a reply or an edit "where the thread would otherwise close", but no thread is selectable while an edit is open, a post is in flight or an upload runs (CommentRow.tsx:422-426, :239), so please word that reason, and the matching comment at CommentComposer.tsx:594-595, for the reply composer only, or stop the click only in reply composers.

Neither new test has run yet: CI skipped its test job on this head, and they could not run in this review. Clicks inside the Comments panel's new-comment composer now bubble too, which the User impact section could mention.

Claims and files checked

Review mode: same-head; reason: none

Title (live): fix(CommentComposer): the caller's onClick runs, and a click bubbles outside a thread

Claims:

  • Title: the caller's onClick runs: verified (CommentComposer.tsx:571-577, :593; the test at CommentComposer.test.tsx:109-126 asserts it runs once).
  • Title: a click bubbles outside a thread: verified (:578, :596-598; of the four composer call sites, the only comment-context ones are the standalone composer and the Comments panel's, Comments.tsx:304-307, :428; reply and edit composers render inside a thread surface, CommentRow.tsx:693, :829, :881-895).
  • On main the composer's own onClick, set after the spread props, replaced the caller's: verified on main.
  • On main every click stopped propagating, so clicks never reached ancestors' click handlers: verified on main.
  • Only a composer inside a thread needs the stop, because an empty-space press would toggle the thread: verified for reply composers (CommentRow.tsx:216-239, useClickableContainer.ts:305-312).
  • The public component API record says event props reach their element and built-in behavior composes with them: verified (INV5, INV7).
  • An audit list flagged this defect on main: reported; the defect itself is verified on main.
  • The fix calls the caller's onClick first and stops only in reply or edit composers: verified.
  • It stops propagation only inside a thread, where the thread would otherwise close: false for edit composers, and for a reply composer while a post or upload is in flight (CommentRow.tsx:422-426, :239).
  • No API, visual or other behavior change: verified; no prop, type, style or markup changes, and the only behavior change is the stated propagation rule, which also covers the Comments panel's new-comment composer.
  • Before the change neither handler runs, and after it both run: reported (your runs); consistent with the code; not yet run in CI.
  • A press in a thread's reply composer keeps the thread open: verified (the test at CommentThread.test.tsx:146-166 contains the case; the kept stop at :596-598).
  • The new composer test fails without the fix: reported.
  • Event wiring only, with no pixel effect: verified.
  • Scope is CommentComposer, one defect, no hidden API, no internal context: verified.
  • Vitest, pnpm review:pre, prettier and eslint pass: reported.
  • Validated on an older main commit: reported.
  • This branch is that work rebased onto an older main commit: false; this head's only parent is a main commit 255 commits later.
  • The commit credits the original author and carries #13738's fix onto current main: verified (co-author line; identical changed lines).
  • #13740, #13736, #13737 and #13735 are separate Comments pull requests: verified (open, separate changes).
  • A replacement of #13739 is stacked on this one: verified (#14158 targets this branch and contains this head).

Files:

  • packages/lab/src/Comments/CommentComposer.tsx: finding (the comment at :594-595 gives the same edit-composer reason).
  • packages/lab/src/Comments/CommentComposer.test.tsx: clear.
  • packages/lab/src/Comments/CommentThread.test.tsx: clear.

Automated review (maintainer link)

@cixzhang

cixzhang commented Dec 1, 2026

Copy link
Copy Markdown
Contributor Author

🤖 (Posted by Cindy's agent.)

Thanks. The Testing section no longer says the branch was rebased. It now names what was checked on the original pull request, and the checks rerun at this head on current main. Only the description changed; the head is unchanged.

… an edit composer's thread is not selectable
@cixzhang

cixzhang commented Dec 1, 2026

Copy link
Copy Markdown
Contributor Author

🤖 (Posted by Cindy's agent.)

Thanks. At 3db24937, the source comment at CommentComposer.tsx and the description say the stop keeps a reply composer's thread from closing. A thread is not selectable while an edit is open, so only the reply case needs it. The Testing section names the bases correctly. The behavior is unchanged.

@cixzhang

cixzhang commented Dec 1, 2026

Copy link
Copy Markdown
Contributor Author

/approve-spec 3db2493

@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. From reading the code, the click fix has no defect: the new composer test fails against the base and passes on this head (reproduced locally), and CI's unit tests pass both new cases on this head.

  • Non-blocking: the first sentence of the comment at CommentComposer.tsx:594 restates the isInThread check below it; the second sentence alone keeps the reason.

Clicks inside the Comments panel's new-comment composer now bubble too, which the User impact section could mention.

Claims and files checked

Review mode: same-head; reason: none

Changed rules (0): none

Title (live): fix(CommentComposer): the caller's onClick runs, and a click bubbles outside a thread

Claims:

  • Title: the caller's onClick runs: verified (CommentComposer.tsx:571-577, :593; the test at CommentComposer.test.tsx:109-126 asserts it runs once and passes in CI's unit tests and locally).
  • Title: a click bubbles outside a thread: verified (:578, :597-599; the only comment-context composers are the standalone one and the Comments panel's, Comments.tsx:304-307, :428; reply and edit composers render inside a thread surface, CommentRow.tsx:693, :829, :881-895).
  • The change is cherry-picked from the original pull request, whose author the commit credits: verified (co-author line in the commit message).
  • On main a standalone composer's caller onClick never runs and its clicks never reach ancestors: verified (the composer's own onClick, set after the spread props, replaced the caller's and stopped every click; reproduced locally against the base).
  • Only a composer inside a thread needs the stop, so an empty-space press does not toggle the thread: verified (CommentRow.tsx:216-239, useClickableContainer.ts:305-312).
  • The public component API record promises that event props reach their element and that built-in behavior composes with them: verified (INV5, INV7).
  • An audit list flagged this defect, confirmed on main: reported; the defect itself is verified on main.
  • The composer calls the caller's onClick first and still stops propagation in reply and edit composers, and only there: verified (:593, :578, :597-599).
  • For a reply composer, the stop keeps an empty-space press from collapsing the thread: verified (the test at CommentThread.test.tsx:146-166 contains the case and passes).
  • No thread is selectable while an edit is open: verified (CommentRow.tsx:422-426; the edit state is shared across the panel).
  • No API, visual or other behavior change: verified; no prop, type, style or markup changes, and the propagation rule also covers the Comments panel's new-comment composer, a composer outside a thread.
  • Before the change neither handler runs, and after it both run: verified (locally against the base the new test's caller handler is called 0 times, and the base's unconditional stop blocks the ancestor; on this head both run, in CI's unit tests and locally).
  • A press in a thread's reply composer keeps the thread open: verified (the test at CommentThread.test.tsx:146-166).
  • The new composer test fails without the fix: verified (reproduced locally against the base).
  • Event wiring only, with no pixel effect: verified.
  • Scope is CommentComposer, one defect, no hidden API, no internal context: verified.
  • This head adds only a corrected source comment on top of the cherry-pick: verified (its commit changes comment lines only).
  • On the original pull request, Vitest, the pre-review checklist, prettier and eslint passed: reported.
  • At the cherry-pick, install, build, tsc, prettier, eslint and the changeset check passed, and the two test files ran 41/41 twice: reported; CI's typecheck, lint and build pass on this head, and the two files run 41/41 in CI and locally.
  • The cherry-pick is clean and sat on the then-current main: verified (its only parent is this pull request's base).
  • This pull request replaces the original with the same change on main: verified (identical changed lines per file, plus the comment fix here).
  • The replacement of the next pull request is stacked on this one: verified (#14158 targets this branch).
  • The four other Comments pull requests are separate changes: verified (open, by the same author, each its own change).

Files:

  • packages/lab/src/Comments/CommentComposer.tsx: non-blocking suggestion (the comment's first sentence at :594 restates the code).
  • packages/lab/src/Comments/CommentComposer.test.tsx: clear.
  • packages/lab/src/Comments/CommentThread.test.tsx: clear.

Automated review (maintainer link)

Comment on lines +594 to +596
// Inside a thread, the click stays in the composer. A press on a
// reply composer's empty space would otherwise reach the thread and
// collapse it.

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.

Non-blocking: the first sentence restates if (isInThread) event.stopPropagation() below it. The reason alone is enough:

// A press on a reply composer's empty space would otherwise reach the thread
// and collapse it.

@cixzhang
cixzhang marked this pull request as ready for review December 1, 2026 21:10

This branch was successfully deployed

1 active deployment
Preview — 3db24937 Deployed Dec 1, 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