Skip to content

fix(post): deleting a comment from the options sheet no longer pops the screen - #3408

Merged
feruzm merged 2 commits into
developmentfrom
fix/comment-delete-navigation
Aug 1, 2026
Merged

fix(post): deleting a comment from the options sheet no longer pops the screen#3408
feruzm merged 2 commits into
developmentfrom
fix/comment-delete-navigation

Conversation

@feruzm

@feruzm feruzm commented Aug 1, 2026

Copy link
Copy Markdown
Member

Closes #3406

postComments.tsx mounted PostOptionsModal for comments with no onDelete, so deleting a comment from the sheet ran the sheet's own path: navigation.goBack() at postOptionsModal.tsx:478, which navigates away from the post the user is reading. It also skipped _handleDeleteComment (postComments.tsx:174), which the same screen already passes to the inline delete button and which owns the error extraction and deleted-key cache handling. The sheet and the button did different things for the same action.

This predates #3405; that PR fixed the same gap for five list surfaces, and this was the remaining comment consumer.

Two parts

The consumer. postComments now passes onDelete forwarding to its existing _handleDeleteComment, with the same five arguments the inline button uses.

The fallback. Relying on every consumer remembering onDelete has not worked - the existing comment on _deletePost already warned about this for waves, and it was still missed twice while adding consumers. Going back only makes sense when the deleted content is the screen, which is true for a root post and false for a comment in a list, so the fallback now pops only for content with no parent_author.

Consumer audit

Consumer onDelete Correct?
wavesScreen yes delegates to wavesQuery.deleteWave
commentsView yes added in #3405
postComments yes this PR
postScreen no correct - deletes the post that is the screen
editorScreen no correct - same
postsListContainer no wrong, but not fixed here

postsListContainer has the same gap for posts in a feed, and no list removal to delegate to. Filed as #3407 rather than half-fixed: a post in a list is indistinguishable from a post on its own screen by content shape, and suppressing the pop without adding removal would leave a stale feed with no feedback that anything happened. That issue also raises whether the prop should be inverted to an opt-in popScreenOnDelete, since forgetting an opt-in leaves you on the screen while forgetting onDelete navigates you away.

Testing

  • yarn test:ci: 730 passed, 1 skipped, 49 suites.
  • yarn lint: 0 errors.

Device checks:

  • Delete your own comment from the sheet on the post detail screen: it should disappear from the list and you should stay on the post.
  • Do the same from a profile comments tab: same result, no navigation.
  • Delete your own root post from its own screen: it should still pop back, unchanged.

Summary by CodeRabbit

  • Bug Fixes
    • Improved comment deletion with optimistic updates, reliable cache handling, and error notifications.
    • Standardized comment deletion from the options menu and confirmation flow.
    • Preserved appropriate navigation behavior after deleting comments or root posts.
    • Added rollback handling so comments reappear when deletion fails.

…he screen

postComments mounted the sheet for comments without an onDelete, so the
sheet's own delete path ran: it called navigation.goBack() and left the
post the user was reading, and skipped _handleDeleteComment, which the
same screen already passes to the inline delete button and which owns the
error extraction and deleted-key cache work.

Passes onDelete forwarding to that handler, with the same arguments the
inline button uses.

Also makes the fallback safe rather than relying on every consumer
remembering. Going back only makes sense when the deleted content is the
screen, which is true for a root post and false for a comment in a list,
so the fallback now pops only for content with no parent. The existing
comment on _deletePost already warned about this and it was still missed
twice while adding consumers.

Audited every PostOptionsModal consumer. postScreen and editorScreen
delete the content that is the screen, so the pop is correct there.
postsListContainer has the same gap for posts in a feed and no list
removal to delegate to; filed as #3407 rather than half-fixed here, since
suppressing the pop without removal would leave a stale feed with no
feedback.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 364ad95d3c

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +487 to +489
if (!content?.parent_author) {
navigation.goBack();
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Preserve navigation after deleting the displayed comment

When the options modal is opened from PostScreen for a comment or wave, that content is the screen itself, but PostScreen mounts the modal without an onDelete callback. This condition therefore deletes the item and leaves the user on its now-deleted detail screen. The new PostComments callback already prevents list deletions from reaching this fallback, so the fallback should continue navigating back after successful deletion.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Both of you caught this independently and you are right - the heuristic was a regression. Reverted in f12935f.

postScreen renders comments and waves as primary content (postScreen.tsx:51 checks parent_author || parent_permlink, :69 gates on depth > 0 && parent_author), and it mounts the sheet with no onDelete. So gating the pop on parent_author left a comment's own detail screen sitting on content that had just been deleted.

The mistake was assuming content shape could stand in for "is this the screen". It cannot: a comment in a list and a comment as the screen are identical objects. Only the caller knows.

So the fallback pops unconditionally again, and consumers that own a surrounding list must pass onDelete. That is now true of all of them except postsListContainer, tracked in #3407.

Worth recording that the safe-by-default goal still stands, it just needs the other shape: an explicit opt-in like popScreenOnDelete rather than inference. Forgetting an opt-in leaves you on the screen, which is mildly wrong; forgetting onDelete navigates you away, which is badly wrong. I have added this attempt and why it failed to #3407 so the next person does not retry the heuristic.

Comment on lines +278 to +280
(comment) =>
_handleDeleteComment(
comment.permlink,

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Avoid showing a second delete confirmation

When deleting a comment from this options menu, PostOptionsModal._deletePost has already shown and received confirmation from its action modal before invoking onDelete. Delegating here to _handleDeleteComment opens the same confirmation flow again, so users must confirm deletion twice (and can cancel the second prompt after confirming the first); delegate to a mutation-only handler or otherwise let only one layer own confirmation.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Correct, fixed in f12935f. PostOptionsModal._deletePost confirms via ACTION_MODAL before invoking onDelete, and _handleDeleteComment then confirmed again, so one delete needed two confirmations and could be cancelled at the second after being confirmed at the first.

Split the handler in two rather than suppressing either prompt:

  • _deleteCommentConfirmed mutates with no prompt, and is what the sheet delegates to
  • _handleDeleteComment prompts and then calls it, for the inline delete button which has no confirmation of its own

That keeps exactly one confirmation on each path and leaves the inline button's behaviour unchanged.

Checked the equivalent path added in #3405: commentsContainer has no confirmation step at all, so commentsView delegating to it was already single-prompt and is unaffected.

@greptile-apps

greptile-apps Bot commented Aug 1, 2026

Copy link
Copy Markdown

Greptile Summary

The PR now routes comment-list deletions through the owning list’s mutation and cache-handling callback while retaining back navigation when the deleted content is the primary screen.

  • Splits confirmed deletion from the inline button’s confirmation flow.
  • Passes an onDelete handler from postComments to prevent the options sheet from popping the post screen.
  • Restores fallback back navigation for primary-content deletion.

Confidence Score: 5/5

The PR appears safe to merge.

No blocking failure remains; the previously reported stale primary-content screen is resolved by navigating back after fallback deletion, while list-owned comment deletion now uses its consumer callback.

Important Files Changed

Filename Overview
src/components/postComments/container/postComments.tsx Separates confirmation from the confirmed mutation and supplies the modal with a list-owned deletion callback that removes the comment without navigating away.
src/components/postOptionsModal/container/postOptionsModal.tsx Restores unconditional back navigation in the fallback deletion path, resolving the previously reported stale comment or wave detail screen.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A[Confirm deletion in PostOptionsModal] --> B{Consumer provides onDelete?}
  B -->|Yes: surrounding list| C[Invoke consumer deletion handler]
  C --> D[Update list/cache and remain on screen]
  B -->|No: primary content| E[Run fallback deletion mutation]
  E --> F[Navigate back from deleted content]
Loading

Reviews (2): Last reviewed commit: "fix(post): drop the parent_author pop he..." | Re-trigger Greptile

Comment thread src/components/postOptionsModal/container/postOptionsModal.tsx Outdated
@coderabbitai

coderabbitai Bot commented Aug 1, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

The post comments screen now centralizes confirmed comment deletion and routes options-modal deletions through the shared flow. The options modal always navigates back for local deletion, while delegated comment deletion remains owned by the caller.

Changes

Comment deletion behavior

Layer / File(s) Summary
Confirmed deletion mutation
src/components/postComments/container/postComments.tsx
_deleteCommentConfirmed performs optimistic hiding, deletion, cache-aware rollback, and error notification. _handleDeleteComment delegates confirmed actions to it.
Deletion routing and navigation guard
src/components/postComments/container/postComments.tsx, src/components/postOptionsModal/container/postOptionsModal.tsx
The options modal passes comment metadata to the shared deletion flow without a second confirmation. Local modal deletion always calls navigation.goBack().

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant User
  participant PostOptionsModal
  participant PostComments
  participant CommentCache
  User->>PostOptionsModal: Select delete
  PostOptionsModal->>PostComments: Pass comment metadata
  PostComments->>CommentCache: Optimistically hide comment
  PostComments->>CommentCache: Delete or restore cached comment
  PostComments-->>User: Show deletion error if mutation fails
Loading

Possibly related PRs

Poem

A rabbit checks the comment trail,
One handler guards the hide and fail.
The modal passes context through,
Cache restores when errors brew.
Root screens hop back on cue.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Linked Issues check ⚠️ Warning The PR fixes delegated comment deletion, but the fallback still calls navigation.goBack() for comments instead of using the required safe navigation gate [#3406]. Gate navigation.goBack() on screen-owned content, or prevent fallback navigation for comments while retaining consumer-provided onDelete handlers.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly describes the comment deletion navigation fix implemented by the pull request.
Out of Scope Changes check ✅ Passed All changes concern comment deletion delegation, confirmation handling, cache updates, error handling, and navigation within the linked issue scope.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/comment-delete-navigation

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
src/components/postComments/container/postComments.tsx (1)

273-276: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Remove the obsolete navigation claim from this comment.

PostOptionsModal now skips navigation.goBack() when content.parent_author identifies a comment. Keep the comment focused on routing through this screen’s error handling and deleted-key cache updates.

Proposed comment update
-    // The sheet is opened for comments here, so its own delete path would call
-    // navigation.goBack() and leave the post the user is reading, and would skip
-    // the error handling and deleted-key cache work this screen already owns.
+    // Route comment deletion through this screen's handler so it preserves the
+    // comment-specific error handling and deleted-key cache updates.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/components/postComments/container/postComments.tsx` around lines 273 -
276, Update the comment adjacent to the PostOptionsModal delete flow in the post
comments container: remove the obsolete claim that the sheet’s delete path calls
navigation.goBack() or leaves the post. Keep only the rationale that this screen
owns the error handling and deleted-key cache updates, while preserving the note
about matching the inline delete button’s arguments.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/components/postComments/container/postComments.tsx`:
- Around line 473-477: Update the comment-deletion flow connecting
PostOptionsModal’s onDelete callback and _handleDeleteComment so only one
confirmation sheet is shown. Make the delegated callback non-confirming, or
disable PostOptionsModal’s confirmation for this path, while preserving the
existing confirmation behavior for other deletion flows.

---

Nitpick comments:
In `@src/components/postComments/container/postComments.tsx`:
- Around line 273-276: Update the comment adjacent to the PostOptionsModal
delete flow in the post comments container: remove the obsolete claim that the
sheet’s delete path calls navigation.goBack() or leaves the post. Keep only the
rationale that this screen owns the error handling and deleted-key cache
updates, while preserving the note about matching the inline delete button’s
arguments.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: e229603c-2fca-48b8-a308-390cab85f02b

📥 Commits

Reviewing files that changed from the base of the PR and between d89f1d7 and 364ad95.

📒 Files selected for processing (2)
  • src/components/postComments/container/postComments.tsx
  • src/components/postOptionsModal/container/postOptionsModal.tsx

Comment thread src/components/postComments/container/postComments.tsx
…mation

Two review findings, both regressions in the previous commit.

postScreen renders comments and waves as primary content, so gating
navigation.goBack() on parent_author left a comment's own detail screen
showing content that had just been deleted. Content shape cannot
distinguish 'comment in a list' from 'comment as the screen' - only the
caller knows - so the fallback pops unconditionally again and consumers
that own a list must pass onDelete. #3407 tracks inverting this into an
explicit opt-in, which is the version that fails safe.

The delete delegation also asked twice: PostOptionsModal confirms before
invoking onDelete, and _handleDeleteComment then confirmed again, so one
action needed two confirmations and could be cancelled at the second
after being confirmed at the first.

Splits that handler in two. _deleteCommentConfirmed mutates without
prompting and is what the sheet delegates to; _handleDeleteComment
prompts and then calls it, for the inline delete button which has no
confirmation of its own.

commentsContainer has no confirmation step, so the equivalent path added
in #3405 was never affected.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
src/components/postComments/container/postComments.tsx (1)

216-221: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Localize the delete-failure toast message.

The error toast in _deleteCommentConfirmed uses a raw hardcoded string, not intl.formatMessage. Every other toast in this file and in postOptionsModal.tsx's delegated-error path uses intl.formatMessage. Localize this message for consistency.

🌐 Proposed fix
-            dispatch(toastNotification(`Failed to delete comment: ${errorDetail}`));
+            dispatch(
+              toastNotification(
+                `${intl.formatMessage({ id: 'alert.fail' })}: ${errorDetail}`,
+              ),
+            );
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/components/postComments/container/postComments.tsx` around lines 216 -
221, Update the delete-failure toast in _deleteCommentConfirmed to use
intl.formatMessage with the existing localized message conventions, preserving
the extracted errorDetail in the rendered message and the current stillExists
branching behavior.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@src/components/postComments/container/postComments.tsx`:
- Around line 216-221: Update the delete-failure toast in
_deleteCommentConfirmed to use intl.formatMessage with the existing localized
message conventions, preserving the extracted errorDetail in the rendered
message and the current stillExists branching behavior.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 5d93a09f-3b3c-4305-84a0-255162536992

📥 Commits

Reviewing files that changed from the base of the PR and between 364ad95 and f12935f.

📒 Files selected for processing (2)
  • src/components/postComments/container/postComments.tsx
  • src/components/postOptionsModal/container/postOptionsModal.tsx

@feruzm
feruzm merged commit 4ff851a into development Aug 1, 2026
15 checks passed
@feruzm
feruzm deleted the fix/comment-delete-navigation branch August 1, 2026 10:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(post): deleting a comment from the options sheet pops the post screen

1 participant