Skip to content

fix(TreeViewListItem): customBadgeContent of number 0 will display #11848

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

Merged

Conversation

adamviktora
Copy link
Contributor

Closes #11845

@patternfly-build
Copy link
Contributor

patternfly-build commented May 27, 2025

@adamviktora adamviktora requested review from a team, rebeccaalpert and wise-king-sullyman and removed request for a team May 28, 2025 08:24
Copy link
Member

@rebeccaalpert rebeccaalpert left a comment

Choose a reason for hiding this comment

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

Code looks good. My only suggestion would be that we add a test for this if you have time.

@adamviktora adamviktora force-pushed the treeViewListItem-custom-badge branch from f6a83e8 to d29a114 Compare May 29, 2025 14:57
Copy link
Member

@rebeccaalpert rebeccaalpert left a comment

Choose a reason for hiding this comment

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

Thank you for the test 🙌

Copy link
Contributor

@thatblindgeye thatblindgeye left a comment

Choose a reason for hiding this comment

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

The code looks good. I think I want to just confirm the use-case for passing 0 to the customBadgeContent when children are also passed. Would the following screenshot be somewhat the intended result? Just using our custom badge example:

image

If so, that I think could be pretty confusing, but it depends on the context (i.e. if the "0" isn't conveying how many children there are, but in that case it'd be better to include some SR text in the badge as well)

Copy link
Contributor

@wise-king-sullyman wise-king-sullyman left a comment

Choose a reason for hiding this comment

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

Howdy stranger! 👋

@adamviktora
Copy link
Contributor Author

Hey everybody! @thatblindgeye Adding a screen reader text is a good idea definitely. Our use case is that the badge indicates number of VirtualMachines under that tree item. But there can also be projects and folders as children:

Screenshot 2025-05-30 at 8 57 21 Screenshot 2025-05-30 at 8 58 01

So e.g. if there are only projects with 0 VirtualMachines, the root should show 0 instead of number of projects.

Copy link
Contributor

@thatblindgeye thatblindgeye left a comment

Choose a reason for hiding this comment

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

@adamviktora ah gotcha. SR text at the least would be helpful, though having the text visible might be better to make it clearer what the 0 means - but depending on the surrounding context or user-familiarity with the product maybe not necessary. This code change LGTM , though.

@thatblindgeye thatblindgeye merged commit 134960a into patternfly:main Jun 2, 2025
13 checks passed
@patternfly-build
Copy link
Contributor

Your changes have been released in:

Thanks for your contribution! 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Bug - TreeViewDataItem - customBadgeContent of number 0 is overwriten
5 participants