Skip to content

Conversation

@UmeraGhori
Copy link
Contributor

What:
This PR adds a confirmation dialog to the "Move to trash" button in the post editor. This ensures users do not accidentally delete posts or pages.

Technical Changes:
Based on previous feedback, I have also refactored how we check if a post type supports the 'trash' feature.

  • Previously: Attempted to check disableTrash in editor settings (which was incorrect).
  • Now: Properly retrieves the post type entity via the @wordpress/core-data store and checks postTypeEntity.supports.trash.
  • Replaced string literals for store selection with proper store imports to comply with linting standards.

Why:

  • Improves User Experience (UX) by preventing accidental data loss.
  • Ensures the code relies on the correct source of truth (Core Data Entity) for post type capabilities.

How to Test:

  1. Open any Post or Page in the Block Editor.
  2. Navigate to the "Summary" panel in the settings sidebar.
  3. Click the "Move to trash" button.
  4. Verify that a confirmation modal appears:
    • If the post supports trash: It asks to "Move to trash".
    • If the post does not support trash: It asks to "Delete permanently".
  5. Confirm that the action only completes after clicking the confirm button inside the dialog.

@github-actions github-actions bot added the [Package] Editor /packages/editor label Dec 30, 2025
@github-actions
Copy link

github-actions bot commented Dec 30, 2025

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: UmeraGhori <[email protected]>
Co-authored-by: Mamaduka <[email protected]>
Co-authored-by: t-hamano <[email protected]>
Co-authored-by: hbhalodia <[email protected]>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@UmeraGhori
Copy link
Contributor Author

@Mamaduka @t-hamano Thanks for the guidance on the previous approach.

I have updated the code to use the core store to check for trash support (postTypeEntity.supports.trash) instead of editor settings. I've also fixed the linting errors. Could you please take a look?

@Mamaduka
Copy link
Member

To my knowledge, and somewhat similar to the proposed solution in #74265, the postTypeEntity.supports.trash settings flag doesn't exist.

If the proposal introduces a new support flag that differs from the suggestions in the original issues, it must be documented in the description.

For now, I think it would be best to move the discussion back to the issue until there's a clear resolution path.

@UmeraGhori
Copy link
Contributor Author

Thanks for the review @Mamaduka.

You are right — I was operating under the assumption that the trash support flag from register_post_type (PHP) was exposed in the REST API supports object. Since that flag doesn't exist in the frontend settings, I agree that we need to define the correct resolution path first.

I will pause this PR and move the discussion back to the issue thread to determine the best way to handle this check.

@t-hamano t-hamano added [Type] Bug An existing feature does not function as intended General Interface Parts of the UI which don't fall neatly under other labels. labels Dec 31, 2025
@t-hamano t-hamano added the [Status] Blocked Used to indicate that a current effort isn't able to move forward label Dec 31, 2025
@Mamaduka
Copy link
Member

@UmeraGhori, the problem is that the supports.trash flag doesn't exist, so of course it's not exposed anywhere. Let's continue the discussion on the issue. If you're unsure about your solution, it's always okay to ask.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

General Interface Parts of the UI which don't fall neatly under other labels. [Package] Editor /packages/editor [Status] Blocked Used to indicate that a current effort isn't able to move forward [Type] Bug An existing feature does not function as intended

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Label of button 'Move to trash' on Settings Panel in Block Editor not changed when constant EMPTY_TRASH_DAYS is defined as 0.

3 participants