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

Fix: Hide empty categories in categories block. #13549

Merged

Conversation

jorgefilipecosta
Copy link
Member

@jorgefilipecosta jorgefilipecosta commented Jan 28, 2019

Description

Fixes: #13440

This PR uses hide_empty option during categories request to make sure categories that have no posts are not displayed in the categories block edit view. On the frontend, they are not rendered so the edit view should replicate that.

Some categories may still show zero as a count. That happens because these categories have descendant categories with posts associated to them.

How has this been tested?

Add the categories block.
Enable the show post count option.
Verify categories with no posts associated to them or one of their descendants don't appear in the edit view.

@jorgefilipecosta jorgefilipecosta added [Type] Bug An existing feature does not function as intended [Package] Block library /packages/block-library [Block] Categories Affects the Categories Block labels Jan 28, 2019
@youknowriad youknowriad added the Good First Review A PR that's suitable for someone looking to contribute for the first time by reviewing code label Jan 29, 2019
Copy link
Member

@Soean Soean left a comment

Choose a reason for hiding this comment

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

Backend (JS):
bildschirmfoto 2019-01-29 um 11 14 18

Frontend (PHP):
bildschirmfoto 2019-01-29 um 11 14 42

In the PHP code, the parent categories also sum up the count of the child categories. Maybe we can solve this with a server side rendered block?
Empty child categories are hidden, the structure is now the same in the frontend and backend, so I think this PR is fine.

@jorgefilipecosta jorgefilipecosta merged commit a13d933 into master Jan 29, 2019
@jorgefilipecosta jorgefilipecosta deleted the fix/hide-empty-cagories-in-categories-block branch January 29, 2019 10:26
@youknowriad youknowriad added this to the 5.0 (Gutenberg) milestone Jan 29, 2019
youknowriad pushed a commit that referenced this pull request Mar 6, 2019
This commit uses hide_empty option during categories request to make sure categories that have no posts are not displayed in the categories block edit view. On the frontend, they are not rendered so the edit view should replicate that.

Some categories may still show zero as a count. That happens because these categories have descendant categories with posts associated to them.
youknowriad pushed a commit that referenced this pull request Mar 6, 2019
This commit uses hide_empty option during categories request to make sure categories that have no posts are not displayed in the categories block edit view. On the frontend, they are not rendered so the edit view should replicate that.

Some categories may still show zero as a count. That happens because these categories have descendant categories with posts associated to them.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Block] Categories Affects the Categories Block Good First Review A PR that's suitable for someone looking to contribute for the first time by reviewing code [Package] Block library /packages/block-library [Type] Bug An existing feature does not function as intended
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants