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

"showCollectionCount" prop, doesn't update to filtered data #113

Open
MattChowski opened this issue Sep 3, 2024 · 1 comment
Open

"showCollectionCount" prop, doesn't update to filtered data #113

MattChowski opened this issue Sep 3, 2024 · 1 comment
Labels
needs discussion question Further information is requested user request Requested by user

Comments

@MattChowski
Copy link

When using "searchText" and "searchFilter" with "showCollectionCount" prop, the collection count doesn't update to the filtered options, resulting in a confusing UX for end users

image

You can see in the image that action_result has 5 items whereas the JSON shows only one, data because I filtered for it.

As a workaround I could probably filter the json on the outside and pass it as a new prop to the JSON viewer but that would re-render more times unnecessarily. I was hoping to use the internal searching functions.

@CarlosNZ
Copy link
Owner

CarlosNZ commented Sep 3, 2024

Yeah, that's a good point, although I'm not totally sure what the "correct" solution would be. Strictly speaking, the search filter is only supposed to be a "display" thing, we're not trying to say that the data isn't there any more, and I think it would be misleading (in some cases at least) to say otherwise.

As a general rule, I would say that if you just want to temporarily hide values for convenience, and the user knows about it, then the current behaviour is correct. However, if you want to truly hide the data and present it to the user as though it was never there, then it's probably best to filter from the outside before passing into the component.

Having said that, I'm not totally sold on this distinction and I can think of cases where the opposite is true in both directions. So I'm open to further discussion.

It would be a reasonable refactor to be able to show the filtered item count (especially to do it in a performant way), so I'd like to get 100% clear on what the preferred/expected behaviour should be before changing anything. At the very least, I think it'd need to be an optional setting, so you could display either the filtered count or the total count (whichever makes most sense for your use case).

In the meantime, you can either:

@CarlosNZ CarlosNZ added question Further information is requested user request Requested by user needs discussion labels Sep 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs discussion question Further information is requested user request Requested by user
Projects
None yet
Development

No branches or pull requests

2 participants