Skip to content
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

PCH Related Top Posts: Add filter values drop-down #1986

Merged
merged 3 commits into from
Nov 13, 2023

Conversation

acicovic
Copy link
Collaborator

@acicovic acicovic commented Nov 8, 2023

Description

This PR introduces the ability to select a specific Tag, Section (Category) or Author value as a way to fine-grain results within the PCH's Related Top Posts panel. Once one of the filter types (let's say Tag) has been selected and the post has more than 1 tags, a second drop-down will be displayed to select the specific tag to filter by.

  • Newly selected tags, categories and author in the Post Editor will be shown immediately as they're getting added/modified, without the need to save the post.
  • Filter types that aren't available (for example when a post doesn't have tags or categories) are not shown as options in the UI.
  • When only a single filter type or value is available, it automatically gets selected without displaying any drop-downs.
  • WordPress Pages don't have tags or categories by design, so they are limited to the author.
  • The filter value drop-down only contains the values that are pertinent to the current post. For example, it won't show all the website's tags, but only the tags that are assigned to the specific post. It is also searchable to accommodate for many entries.
  • This implementation doesn't current support the Co-Authors Plus plugin. This possibility will be investigated in the future.

Motivation and context

How has this been tested?

Some existing tests were slightly modified to pass. The testing was manual and there are no automated tests specifically targeting filter type and value selection.

Screenshots

The filter type drop-down

Shown Clicked
image image
No category (section) assigned to the post No tag or section, auto-fallback to author
image image

The filter value drop-down

Post with many tags (collapsed) Post with many tags (expanded)
image image

The same view/functionality applies in the case of many categories or authors.

@acicovic acicovic added this to the 3.11.0 milestone Nov 8, 2023
@acicovic acicovic self-assigned this Nov 8, 2023
@acicovic acicovic changed the title PCH Related Top Posts: Add filter values selection PCH Related Top Posts: Add filter values drop-down Nov 9, 2023
@acicovic acicovic marked this pull request as ready for review November 9, 2023 08:26
@acicovic acicovic requested a review from a team as a code owner November 9, 2023 08:26
Copy link
Contributor

@vaurdan vaurdan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me! :) I have added an inline comment with a question, but otherwise, no blockers from me.

Regarding the need to refresh to get co-authors, the problem is related with the fact that the CAP terms are only added to the post on save, and therefore the new local API endpoint returns no co-authors, making the filter either empty or outdated, right?

src/content-helper/editor-sidebar/editor-sidebar.tsx Outdated Show resolved Hide resolved
@acicovic
Copy link
Collaborator Author

acicovic commented Nov 9, 2023

Regarding the need to refresh to get co-authors, the problem is related with the fact that the CAP terms are only added to the post on save, and therefore the new local API endpoint returns no co-authors, making the filter either empty or outdated, right?

I haven't dug in detail about why this is exactly happening so I don't know, but it does feel quirky in regular use to the point I'm thinking of temporarily dropping Co-Authors support and directly getting the Author from Gutenberg. The final solution would be to get co-authors data from Gutenberg as well, as we can do with the other data.

@acicovic
Copy link
Collaborator Author

acicovic commented Nov 9, 2023

I'm dropping Co-Authors support for now, to make the user experience better. We can then sort out in time how to get the data from the plugin.

@acicovic
Copy link
Collaborator Author

acicovic commented Nov 9, 2023

I've removed Co-Authors Plus support, and modified the PR's description to reflect that.

@acicovic acicovic requested a review from vaurdan November 9, 2023 15:16
Copy link
Contributor

@vaurdan vaurdan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great! 👍

Base automatically changed from update/implement-base-endpoint-class to develop November 13, 2023 09:19
@acicovic acicovic merged commit 7f48342 into develop Nov 13, 2023
38 checks passed
@acicovic acicovic deleted the add/pch-related-top-posts-filter-values-selection branch November 13, 2023 09:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

PCH Related Top Posts: Allow user to choose meta filter(s)
2 participants