WordPress / gutenberg

The Block Editor project for WordPress and beyond. Plugin is available from the official repository.
https://wordpress.org/gutenberg/
Other
10.51k stars 4.2k forks source link

Comments Loop Block: Tracking issue #34994

Closed SantosGuillamot closed 2 years ago

SantosGuillamot commented 3 years ago

Description

The idea of this issue is to end up with a Comments Loop Block (name may change) that loops over the comments of a given post. This would be similar to the Query Loop used for posts. Users should be able to define and change the layout of the post comments directly from the Gutenberg editor, and both the editor and the frontend should match.

This is how the different comment blocks should look like:

Comments Query Loop

https://excalidraw.com/#json=6537760064143360,EgfZIljXt2SI2DTSFebHQQ

Existing Solution / Workaround

Right now, there are two similar blocks:

Tasks

These are the steps we should follow to finish the tracking issue:

Please note that I'll be adding the relevant issues once they are created.

Out of scope

There are some functionalities that could be nice to work on but that won't be covered in this tracking issue, although they may be addressed later in the future:

Questions

Of course, any feedback apart from these questions is more than welcome 🙂

Previous work

There has been already some work done related to the Comments Block that was tracked in this issue → https://github.com/WordPress/gutenberg/issues/24101

gziolo commented 2 years ago

We caught two issues during backporting the latest changes to WordPress core:

  1. A simple fix to sort out whitespaces to follow WP coding standards: https://github.com/WordPress/gutenberg/blob/1e830c288322b3de97d679a1bf0ad34e2ef85f1a/packages/block-library/src/comments-title/index.php#L56-L68
  2. The hook that is added globally in the Post Comments Form will also impact the Post Comments block: https://github.com/WordPress/gutenberg/blob/1e830c288322b3de97d679a1bf0ad34e2ef85f1a/packages/block-library/src/post-comments-form/index.php#L58-L73 It should get applied in the render callback and removed after the output content is ready.
gziolo commented 2 years ago

Another small thing caught while testing in WordPress core.

Post Comments block on the front end:

Screenshot 2022-04-26 at 15 09 54

Comments Query Loop on the front end:

Screenshot 2022-04-26 at 15 09 48
cbravobernal commented 2 years ago

Regarding the title size, is because we used h2 instead of h3. As @justintadlock recommended. We can go back and set the h3 as a default. https://github.com/WordPress/gutenberg/pull/40419#issuecomment-1101769218

Regarding the date, we have a selector in the block that allows you to choose the date format. We can set with hours and minutes by default. Adding the 'at' would be trickier though. Also, the format is usually defined by the theme. In our block, we get the default format from the date settings.

Regarding the Author, we can address an issue to include a plaintext like in the Comments Title, so the user can write "says:", putting it as a default.

gziolo commented 2 years ago

Please note also "3 Responses" vs "3 responses".

ockham commented 2 years ago

Thanks @gziolo! Working on fixing those here: #40628.

peterwilsoncc commented 2 years ago

As Beta 3 was the string freeze (no new strings), could the comment's title block use the same ones as in the template. This will avoid breaking the freeze & reduce the number of strings requiring translations.

<?php
if ( 1 == get_comments_number() ) {
    printf(
        /* translators: %s: Post title. */
        __( 'One response to %s' ),
        '&#8220;' . get_the_title() . '&#8221;'
    );
} else {
    printf(
        /* translators: 1: Number of comments, 2: Post title. */
        _n( '%1$s response to %2$s', '%1$s responses to %2$s', get_comments_number() ),
        number_format_i18n( get_comments_number() ),
        '&#8220;' . get_the_title() . '&#8221;'
    );
}
?>

-- source

I think the logic will need to be more complex to allow for users modifying the title in the block.

cbravobernal commented 2 years ago

Please note also "3 Responses" vs "3 responses".

Now with the block, we are allowing some more options like:

Covering all those different options with different strings for uppercase/lowercase would be hard to maintain. I put it as an uppercase to cover when the Comments Count is hidden, but we can do it the other way. In both cases, the user will need to update the string if they change the default layout, according to their language.

Also, as @ockham mentioned in the title PR, there is the possibility of having more than two different ways of plurals, so we should find a way to translate _n functionality into blocks.

ockham commented 2 years ago

Please note also "3 Responses" vs "3 responses".

This is being addressed by @c4rl0sbr4v0's https://github.com/WordPress/gutenberg/pull/40728.

SantosGuillamot commented 2 years ago

This is the progress of the latest Pull Requests. The changes made in the PRs that are backported will be included in 6.0 version. If I am not mistaken, the other ones will have to wait for future versions (6.0.1 is expected in June/July).

Feel free to correct me or add anything missing 🙂

Merged and backported in beta/RC

Merged but NOT backported

Not finished yet

ockham commented 2 years ago

@SantosGuillamot I updated your comment to add two links to issues that I created (plus one for a PR).

annezazu commented 2 years ago

Anything else you think we should address and not covered here?

In case it's helpful, some feedback came in through the FSE Outreach Program for the fourteenth call for testing that explored these new blocks. Specifically, the following ideas were thrown out:

Happy to open individual issues for these if it's desired but wanted to lightly put on the radar for now as possible ideas to consider.

cbravobernal commented 2 years ago

Thanks for the feedback @annezazu 🎉 😄

A block that shows how many people have commented total (across the whole site rather than just the post)

There is already a Post Comments Count block, so we may just add an option to display the whole site comments count. It could be a Good First Issue if the community wants this feature. But I don't know if this would be a good Core block feature.

A block that shows when the last comment happened

Would be this one just a date? I cannot find any use case here, but, with Latest Comments block, you can achieve something similar.

Screenshot 2022-05-25 at 11 53 19
annezazu commented 2 years ago

Would be this one just a date? I cannot find any use case here, but, with Latest Comments block, you can achieve something similar.

Yes! Just the date as a way to show perhaps more active commenting areas compared to others. Neat to see you can do this already with latest comments block 💥

ockham commented 2 years ago

Hey @annezazu , thanks a lot for the feedback! 😄

Specifically, the following ideas were thrown out:

  • A block that shows when the last comment happened
  • A block that shows how many people have commented total (across the whole site rather than just the post)

While those make sense, I’m afraid the team won’t prioritize these blocks in the near future. TBH, since their use cases seem a bit less common than our garden variety Comments blocks, I think it’s arguable that they could be third-party plugin material — especially the latter; and for the former, there’s the Latest Comments block that @c4rl0sbr4v0 pointed out that could serve as a substitute. If you think it would still make sense to have issues for those in the GB repo (potentially to discuss that these blocks should be in GB/Core), please go ahead and file them 😊🙏


FWIW, we’re going to close this tracking issue soon (since WP 6.0 has been released), and will file a new one with a list of some smaller follow-up fixes for WP 6.0.1 (but we won’t be introducing any new blocks there). Beyond that, the @WordPress/frontend-dx team will be focusing on Block Frontend Hydration, and on modularizing the Post Comments Form block.

ZebulanStanphill commented 2 years ago
  • A block that shows when the last comment happened

  • A block that shows how many people have commented total (across the whole site rather than just the post)

These sound like ideas more suited for the dynamic tokens concept discussed in #39831, rather than blocks.

SantosGuillamot commented 2 years ago

Closing this in favor of #41451