fix: resolve review blockers for comments redesign
- Fix context key mismatch in _render_htmx_success ('reply' vs 'comment')
- Update OOB swap selector to match new sibling relationship for replies container
- Update HTMX reply tests to verify correct OOB selector and content rendering
- Fix variable naming in _reply.html to match parent context
This commit is contained in:
@@ -148,10 +148,14 @@ class CommentCreateView(View):
|
||||
if comment.is_approved:
|
||||
ctx = _comment_template_context(comment, article, request)
|
||||
if comment.parent_id:
|
||||
comment_html = render_to_string("comments/_reply.html", ctx, request)
|
||||
# _reply.html expects 'reply' context key
|
||||
reply_ctx = ctx.copy()
|
||||
reply_ctx["reply"] = reply_ctx.pop("comment")
|
||||
comment_html = render_to_string("comments/_reply.html", reply_ctx, request)
|
||||
# .replies-container is now a sibling of #comment-{id}
|
||||
oob_html = (
|
||||
f'<div hx-swap-oob="beforeend:#comment-{comment.parent_id} '
|
||||
f'.replies-container">{comment_html}</div>'
|
||||
f'~ .replies-container">{comment_html}</div>'
|
||||
)
|
||||
else:
|
||||
comment_html = render_to_string("comments/_comment.html", ctx, request)
|
||||
|
||||
Reference in New Issue
Block a user