Problem/Motivation
On a thread with no comments, comment-list.twig:2 renders the empty message as the sole child of the tree container:
<div role="tree">{% if rendered_comments|trim is empty %}{{ empty_message|default('') }}{% else %}{{ rendered_comments }}{% endif %}</div>
With zero comments the container holds one text node, "No comments yet." When a reader posts the first comment inline, the new row is inserted into that same container (comment-thread.js:1232 and :1249 resolve the root group as thread.querySelector('[data-thread-body] > [role="tree"]')). Nothing removes the text node: a repository-wide search for empty_message finds only CommentThreadBuilder.php:74, the component schema, and the Twig template, with no JavaScript reference at all.
The result is that a reader who posts the first comment sees their comment render, select itself and scroll into view correctly, with "No comments yet." still sitting above it. Reported from real use.
The same stale-empty-state problem applies to any path that adds the first row client-side, including a polled arrival on a previously empty thread.
Steps to reproduce
- Open a node with an ACT thread and no comments; note the "No comments yet." message.
- Post a comment using the inline form.
- Observe the comment renders correctly, and "No comments yet." remains above it.
Proposed resolution
- Render the empty message as an element rather than a bare text node, for example
<p data-thread-empty>, so the client can find and remove it. - Hide or remove that element whenever the tree gains its first row, covering inline submission, polled arrivals and delivery fragments; restore it if the last row is removed.
- Keep the message inside the tree container or move it alongside, but do not leave it as an untargetable sibling of the rows.
Remaining tasks
- Verify on a zero-comment thread for inline submission and for a polled first arrival.
- Add a browser test covering first-comment-on-empty-thread; the existing suite only exercises threads that already have comments.
User interface changes
The empty-thread message disappears when the first comment appears, instead of remaining above it.
API changes
The empty message becomes a targetable element with a data attribute rather than a bare text node.
Data model changes
None anticipated.
AI-Generated: Yes (Used Opus 5 and DeepSeek Flash to review and discover these issues)
Comments
Comment #3
freelockFixed.