Skip to content

Comments Blocks Warnings: Add buttons to resolve warnings #40614

@ockham

Description

@ockham

Based on #40563 (comment) and #40563 (comment).

The Comments Query Loop block (soon to be renamed to just "Comments") and its child blocks currently use the <Warning /> component in a few places, in order to indicate that what the user will see on the frontend might not match their expectations, e.g. if comments are not enabled for the entire site, the current post (or page), or the corresponding post type.

image

While it's debatable whether or not the <Warning /> component is the best fit here, that's for another issue.

However, regardless of how we preset this information to the user, it'd be better if we actually gave them the agency to change whatever is preventing the Comments Query Loop (or part of it) to show up on the frontend. I.e. if comments are disabled for a post or page with a certain ID, we could add a button to enable them; or if they're disabled for an entire post type, we could add a button that either enables them right away, or at least takes them to the relevant settings screen.

(It's much less frustrating for a user if they're presented with a problem and a potential solution, rather than just the problem, and they're on their own to figure out the solution.)

FWIW, the <Warning /> components supports adding primary and secondary actions: https://github.com/WordPress/gutenberg/blob/trunk/packages/block-editor/src/components/warning/README.md

As seen in BlockInvalidWarning:

warning-block-invalid

As seen in withMultipleValidation:

warning-block-use-once

Where possible, we should add one primary button per warning that will immediately change the setting such that the corresponding part of the block will be displayed on the frontend, and make the warning go away. If that's not possible, let's add a secondary button that takes the user to the relevant settings page where they can change that setting.

I'll post a live comment below with a list of Warnings that need those changes.

Metadata

Metadata

Assignees

No one assigned

    Labels

    [Block] CommentsAffects the Comments Block - formerly known as Comments Query Loop[Type] EnhancementA suggestion for improvement.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions