Fix comments UI nullable reply HTML handling#28938
Open
PedroMarianoAlmeida wants to merge 2 commits into
Open
Conversation
Guard nullable comment HTML before rendering bodies or generating reply snippets, and only pass concrete open reply forms to ReplyFormBox.
Contributor
WalkthroughComment rendering now treats missing HTML as absent content: opening the inline reply form is blocked when a published comment has no HTML, published bodies render only when HTML exists, and both published and unpublished layouts require an open form before showing the reply form. The e2e suite adds coverage for a deleted reply with null HTML rendering as a tombstone without action controls while a nested visible child reply remains visible. 🚥 Pre-merge checks | ✅ 4✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Why I am making it
This started as a comments-ui typecheck cleanup.
Comment.htmlis typed asstring | null, because deleted comment replies can be returned withhtml: nullwhen they need to stay visible as tombstones for visible descendant replies.Some reply paths still treated
comment.htmlas always being a string when rendering or building the “reply to” snippet. This makes those paths narrow nullable HTML explicitly and adds regression coverage for the deleted reply tombstone case.What it does
null.ReplyFormBoxwhen anopenFormexists.html: nulland a visible child reply.Type errors fixed
This removes the
apps/comments-ui/src/components/content/comment.tsxerrors caused by nullable comment HTML and optional reply form state:Argument of type 'Comment' is not assignable to parameter of type '{ html?: string | undefined; }'Type 'string | null' is not assignable to type 'string | undefined'Type 'OpenCommentForm | undefined' is not assignable to type 'OpenCommentForm'Type 'string | null' is not assignable to type 'string'Why developers need it
This cleans up the comments-ui typecheck path and protects the threaded comments UI from crashing or exposing actions for deleted reply tombstones when API data contains
html: null.Testing
rtk pnpm --filter @tryghost/comments-ui test:acceptance test/e2e/content.test.tsrtk pnpm --dir apps/comments-ui exec eslint --cache -- test/e2e/content.test.ts0with the existing warning that the test file is ignored because comments-ui lint config only targetssrc.Checklist