-
Notifications
You must be signed in to change notification settings - Fork 4.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix comments query loop pagination not respecting Discussion Settings #40284
Fix comments query loop pagination not respecting Discussion Settings #40284
Conversation
+ fix possible error where if someone set more than 100 it would return zero results in the editor but work ok when rendered by the backend
These CI failures don't seem to be related Noticed a 6 hours job timeout issue that creates $$$ and CO2 overhead. I've shared more on #core-editor slack thread |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @tomasztunik ! Very nice PR 👏
// controls. We don't want to remove them from the template so that when the user enables | ||
// paging comments, the controls will be visible. | ||
if ( ! pageComments ) { | ||
return null; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we should explain why the editor doesn't display the actual pagination.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added a comment 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for the confusion. I meant explaining to the user. Currently, this will render nothing, and folks might think it's a bug.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah thought it might be one of the two but this was quick enough that decided to see if it was the right call :)
Can you point me toward an example for similar conditional controls/UI elements? If we were to announce it to the user better - would it be better to just render the control but annotate it as "hidden" because of a setting, or render a warning/placeholder saying pagination would be here but it is disabled by settings?
Will roll back the comment for now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The only thing that comes to mind is the Reusable block message that it cannot be rendered inside itself 😅 We can probably skip the warning wrapper.
{ __( 'Block cannot be rendered inside itself.' ) } |
Do you know who was leading design efforts for the Comment blocks? Maybe they have suggestions as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've pushed the code but now I'm thinking... should "Discussion Settings" be a link? :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, not sure about that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not 100% convinced that we should add the <Warning />
here if the lack of pagination is the expected and correct behaviour. I would lean towards not rendering any additional UI elements.
I think it might be confusing if we use the same UI element when there is an actual error (e.g. when we show the This block has encountered an error and cannot be previewed
) and also use this element to just inform the user why no pagination is being displayed.
@jameskoster was involved in the design of some of the Comment blocks so perhaps he'd like to chime in?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've had a quick look and the <Warning />
component seems to be used in a couple of other blocks including comments related blocks to inform about data availability and settings state. Ie. PostCommentsForm. The message though could be aligned with these as they all include the block name with a message following it.
I think there is value in the warning, and semantically it seems correct if we assume that the warning is not for the user who disabled the pagination but rather a warning to let other users (or the future "me") working with the blocks about why the pagination is not there as there is no obvious way to learn that without remembering to go to settings to review that.
waiting for more insights here :)
(updated the copy to match how warnings are used in other comments related blocks)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, that makes sense. I withdraw my objections since there is precedent for using the <Warning/>
to inform rather than show errors as you point out. 🙂
Re: the copy - I think it makes sense if we link to the Discussion settings. The only problem is that I don't see a reliable way to determine the admin URL. There was something custom added to that effect as a global window.wpAdminManifestL10n
which is then used here but it's an experimental package and we can't rely on it.
Co-authored-by: George Mamadashvili <[email protected]>
this is to enable styling the controls regardless of data and state
This will take place of the pagination placeholder. + Remove unneeded comment about comments pagination being a placeholder.
Thanks for the PR! Are 100 results a lot to show in the editor? This could affect the performance and the editing experience. I guess there won't be many cases of users adding this out of the Site Editor (like in a post or page), but I guess that limiting the results to about 10 would be a good number. |
Good point, but then if there are is more data should we show a warning
that results are limited in the editor?
pon., 18 kwi 2022, 10:36 użytkownik Carlos Bravo ***@***.***>
napisał:
… Thanks for the PR!
Are 100 results a lot to show in the editor?
This could affect the performance and the editing experience. I guess
there won't be many cases of users adding this out of the Site Editor (like
in a post or page), but I guess that limiting the results to about 10 would
be a good number.
—
Reply to this email directly, view it on GitHub
<#40284 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAA3NDX2PKHCCXWY36A34GLVFUNJTANCNFSM5TIXCW7Q>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
Another option could be to show that information on the block description. I'm not sure if always showing a warning is a good UX. Let's add a |
Answer from design contributors, link to slack:
Let's address it in another PR @tomasztunik , thanks for the contribution! |
…#40284) * hide comments pagination in the editor if not enabled * if comments pagination not enabled fetch max allowed items + fix possible error where if someone set more than 100 it would return zero results in the editor but work ok when rendered by the backend * update selector to return only used data Co-authored-by: George Mamadashvili <[email protected]> * clarify that in editor we are rendering pagination placeholder this is to enable styling the controls regardless of data and state * Present a user facing warning if comments pagination was disabled. This will take place of the pagination placeholder. + Remove unneeded comment about comments pagination being a placeholder. * align disabled comments warning copy with other comments blocks Co-authored-by: George Mamadashvili <[email protected]>
Cherry-picked to the |
What?
Fixes so that Comments Query Loop block respects Discussion settings if comments pagination is disabled.
Fixes #39444
Why?
Currently, if in the Discussion Settings paginating comments was not enabled PHP on the front-end would correctly render all comments and would not render the pagination. In the editor, these settings were not respected. Pagination was rendered and the set
per_page
value would be reflected in the number of rendered comments.How?
On the editor side, I've added checking if paginating comments was enabled and if so I made the comments-pagination/editor not render and made sure that
Gotchas! 💣 💥
Testing Instructions
cc: @c4rl0sbr4v0 @Mamaduka