Skip to content

fix(comments): enforce Core parity for spam and trash row actions. - #931

Open
KarunyaChavan wants to merge 5 commits into
WordPress:trunkfrom
KarunyaChavan:fix/comments-restore-not-spam-actions
Open

KarunyaChavan wants to merge 5 commits into
WordPress:trunkfrom
KarunyaChavan:fix/comments-restore-not-spam-actions

Conversation

@KarunyaChavan

@KarunyaChavan KarunyaChavan commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

This PR fixes the action button mismatch in the native Comments window by aligning the available actions for "spam" and "trash" comments with WordPress Core's class-wp-comments-list-table.php.

Closes #918

Why?

The original App Framework port of the comments window unintentionally omitted the status guards on row actions. This led to a few UX and logical bugs:

  • Incoherent Actions: Users could attempt to "Reply" to or "Edit" a quarantined comment, which doesn't make sense since they cannot be publicly displayed until restored.
  • Destructive Fallback: Spammed or trashed comments showed "Approve" instead of "Not Spam" or "Restore". Clicking "Approve" bypassed the moderation queue and permanently deleted the comment's previous state, forcing it immediately live.
  • Missing Workflows: The standard restorative actions were completely absent from the UI.

What Changed?

Tab Before After
Spam before-spam_tab after-spam_tab
Trash before-trash_tab after-trash_tab
  • Replaced "Approve" for quarantined comments:
    • In the Spam tab, "Approve" is replaced with "Not Spam" (routes to wp_unspam_comment).
    • In the Trash tab, "Approve" is replaced with "Restore" (routes to wp_untrash_comment).
  • Suppressed "Reply" and "Edit" for quarantined comments:
    • Introduced an isQuarantined flag (status === 'spam' || status === 'trash'). If true, the Reply and Edit buttons are hidden, mirroring Core's exact guard.
  • Preserved "Trash" on spam rows:
    • Left the "Trash" button visible on spam rows so users can still route spam into the Recycle Bin for eventual permanent deletion (as OpenStation deliberately avoids direct permanent deletion in this window).
  • Added Test Coverage:
    • Added missing Vitest coverage to assert the exact action sets rendered for spam and trash statuses.
    • Added dispatch tests to verify that unspam and untrash fire correctly without requiring confirmation dialogs.

Steps for Testing

  • Toggle ON "Use the native Comments Window" in Settings.
  • Open the Comments app and move at least two comments to Spam and two to Trash.
  • Switch to the Spam tab. Verify that:
    • The actions shown are Not Spam and Trash.
    • Approve, Reply, and Edit are NOT visible.
    • Clicking Not Spam successfully restores the comment without a confirmation dialog.
  • Switch to the Trash tab. Verify that:
    • The actions shown are Restore and Spam.
    • Approve, Reply, Edit, and Trash are NOT visible.
    • Clicking Restore successfully moves the comment back to its previous state without a confirmation dialog.
Open WordPress Playground Preview

- Replace the universal "Approve" button with "Not Spam" in the Spam tab.
- Replace "Approve" with "Restore" in the Trash tab.
- Route both actions to their correct Core functions (`wp_unspam_comment` and `wp_untrash_comment`).
- Prevent data loss: using "Approve" previously destroyed `_wp_trash_meta_status`, forcing pending comments to bypass moderation and become published.
- Align behavior with Classic admin, which hides the Approve button in these views for this exact reason.
* Replace universal "Approve" with "Not Spam" (unspam) in the Spam tab.
* Replace "Approve" with "Restore" (untrash) in the Trash tab.
* Suppress Reply and Edit for spam/trash rows - replying under a quarantined parent is incoherent; editing offers no value before restoring.
* Keep Trash visible on spam rows so the Recycle Bin remains the permanent-deletion path.
* Assert spam row renders [Not Spam, Trash] - no Approve, Reply or Edit.
* Assert trash row renders [Restore, Spam] - no Approve, Reply, Edit or Trash.
* Assert Not Spam dispatches unspam with no confirmation; Restore dispatches untrash with no confirmation.
@KarunyaChavan
KarunyaChavan marked this pull request as ready for review October 1, 2026 08:34
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.

Native Comments Window is missing "Restore" and "Not Spam" actions in Trash/Spam tabs

1 participant