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

Display active table filter count #1689

Closed
mturoci opened this issue Nov 8, 2022 · 17 comments · Fixed by #2371 · May be fixed by Ultare1717/wave#1 or #2220
Closed

Display active table filter count #1689

mturoci opened this issue Nov 8, 2022 · 17 comments · Fixed by #2371 · May be fixed by Ultare1717/wave#1 or #2220
Labels
feature Feature request good first issue Contributions welcome! ui Related to UI

Comments

@mturoci
Copy link
Collaborator

mturoci commented Nov 8, 2022

via @shihan007

The table currently supports filtering, but to see how many filters are active per column, one needs to click it and see which filter options are checked.

Instead, we could display the filter count in the top right corner relative to the chevron icon so that it's visible without clicking the chevron.

image

Implementation note: If there are > 9 filters active, display 9+ instead of the actual number to prevent too big count numbers and related spacing problems.

@mturoci mturoci added ui Related to UI feature Feature request labels Nov 8, 2022
@mturoci mturoci added the good first issue Contributions welcome! label Nov 30, 2022
@jding712
Copy link

Hi me and other friends would like to take on this issue.

@mturoci
Copy link
Collaborator Author

mturoci commented Dec 13, 2022

Go ahead @jding712!

@mturoci
Copy link
Collaborator Author

mturoci commented Jan 10, 2023

The issue is up for grabs again for anyone interested.

@Stijn-Kuijper
Copy link

Hi,

I was looking into fixing this, but as far as I can tell Fluent UI does not allow you to add custom elements to an IColumn. A different solution that is possible would be to use the Tooltip to show the amount of filters when hovering over the column header label.

I've made a start at this approach, and it would look something like this:
image

Would this be a satisfactory solution? If so, I can continue to fix this issue. If not I'm afraid it will be too difficult for me to fix.

@mturoci
Copy link
Collaborator Author

mturoci commented Mar 29, 2023

Thanks for your interest @Stijn-Kuijper!

Fluent UI does not allow you to add custom elements to an IColumn

Looking at the Fluent API, it seems like onRenderHeader might be what is needed.
image

use the Tooltip to show the amount of filters when hovering

Although this is an option, it may not be the optimal UX we are striving for as it would require an additional hover to show the counts.

@Stijn-Kuijper
Copy link

Hi, thanks for the quick reply!

onRenderHeader is actually what I am using right now to use the tooltip. However, this seems to only replace the content/label of the column header, rather than the entire header element. I tried adding a div element there that would have two children: one with the label and one with the filter amount, but this did not seem like an appropriate way of going about doing this, which is why I switched over to the tooltip approach.

Additionally, using onRenderHeader would mean the amount of filters would be displayed between the label and the chevron and some absolute positioning trickery would likely have to be used to get it displayed to the right of the chevron.

@mturoci
Copy link
Collaborator Author

mturoci commented Mar 29, 2023

However, this seems to only replace the content/label of the column header, rather than the entire header element.

Not sure I understood this fully. Are you saying this doesn't replace things like sorting/filter icons as well, but just the text? If so, the proper solution would be to render both sort/filter within the custom renderFunction. In fact, this would also make the onColumnClick better since no ugly isMenuClicked hacks would be needed.

using onRenderHeader would mean the amount of filters would be displayed between the label and the chevron and some absolute positioning trickery would likely have to be used to get it displayed to the right of the chevron.

This should be achievable by absolute positioning relative to the filter chevron.

@Stijn-Kuijper
Copy link

Are you saying this doesn't replace things like sorting/filter icons as well, but just the text?

This seems to be the case. Making changes in the onRenderHeader will not change the chevron in any way for example.

If so, the proper solution would be to render both sort/filter within the custom renderFunction.

Does this mean the label, chevron and active filter count should all be rendered within the onRenderHeader? And thus the columnActionsMode should just always be set to clickable?

@mturoci
Copy link
Collaborator Author

mturoci commented Mar 29, 2023

Does this mean the label, chevron and active filter count should all be rendered within the onRenderHeader? And thus the columnActionsMode should just always be set to clickable?

That's exactly what I think. Feel free to reach out if other assistance is needed. Btw, we also have Discord that may be better for such-realtime discussions.

@Stijn-Kuijper
Copy link

In that case I will have a look the coming days to see if I can come up with a fix. If I run into any more issues I'll make sure to run it by the discord first. Thanks for the help!

@Ultare1717
Copy link

Ultare1717 commented Nov 20, 2023

Hello!! Is this issue still open. If yes me and my group would like to work on it?

@mturoci
Copy link
Collaborator Author

mturoci commented Nov 20, 2023

Yes, it's open. Feel free to make a PR :)

@Ultare1717
Copy link

image

Would something like this do?

@mturoci
Copy link
Collaborator Author

mturoci commented Dec 8, 2023

Would something like this do?

Something like that yes, but ideally following the design outlined in the description. Non need to also add the selection count within context menu.

@johannes-becker-otto
Copy link

maybe it would already be sufficient to change the open downward triangle to a filled downward triangle?
So V --> ▼
Cheers
Hannes

dbranley added a commit to dbranley/wave that referenced this issue Jul 17, 2024
@dbranley
Copy link
Contributor

Hello Wave,

I have a solution for this change request to display a filter count on tables.

As requested in the ticket, I have updated the table component so that it will display a count of selected options just to the top right of the chevron down icon. As suggested, I used onRenderHeader to accomplish this - this means the custom renderer for the column now displays the name, sort icon, chevron icon and count. The code changes are in ui/src/table.tsx and here is a screen shot of what it looks like:

issue1689_output_example

And here is a short video demonstrating the filtering after this change:

issue1689_ui-test.mov

I added 3 new unit tests to ui/src/table.test.tsx that check for the new filter counts. These pass along with all the other unit tests. Here is a screen shot of the results from running all the regression tests:

issue1689_unit-tests_after

Question for you: The count is being rendered in red with a red border to match how the requirement is defined in the ticket. I wasn't sure if that was done in red make it stand-out in the screen shot or if this is how it was supposed to be implemented. Can you confirm if red text with red border is what you expect?

I have a branch in my fork of the project and will be submitting a PR once I hear back about the styling of the new filter count. Let me know if this looks ok. Thanks!

@dbranley
Copy link
Contributor

Hi,
I decided to go ahead with the PR and put the question about the text/border color into the PR. Let me know if there's anything you need me to change.
thanks,
Dan

dbranley added a commit to dbranley/wave that referenced this issue Aug 8, 2024
…esign, applied refactor suggestions, split select-deselect test cases and added reset test h2oai#1689
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature Feature request good first issue Contributions welcome! ui Related to UI
Projects
None yet
6 participants