githubocto / flat-ui

MIT License
370 stars 23 forks source link

Multiselect on categories #21

Open nikodraca opened 2 years ago

nikodraca commented 2 years ago

It would be great if you could multiselect values on category fields. Currently you can only select one category to filter on.

Any interest in this? I don't mind taking a crack at it.

Wattenberger commented 2 years ago

we would definitely be open to a PR on this, thanks!

nikodraca commented 2 years ago

@Wattenberger would you be able to give me permissions to make PRs 🙏?

Wattenberger commented 2 years ago

@nikodraca do you mind forking the repo and creating a PR from there? Similar to this PR: https://github.com/githubocto/flat-ui/pull/10

nikodraca commented 2 years ago

@Wattenberger revisiting this now that I have a better understanding of the codebase - I think the first item of work is multiselect on category fields. I believe this will be doable with Downshift (though I don't have any experience with it).

The second item of work, which I think requires a larger discussion, is about filtering on array fields:

Excited to contribute 😄

Wattenberger commented 2 years ago

is filtering by array fields a feature you/others would want? Personally I have a use case where I'd like to be able to filter on multiple items of an array (ie. give me all rows where the array includes X or Y)

I bet we'll be able to add multiselect in a way that doesn't detract from the single-select use case. If so, I bet a lot of people would find it useful!

is there a reason to display X item(s) in the cell vs something like a stringified array for array fields? I can't quite figure out the difference between a short-array and array, could you explain this to me?

I think these questions are related. We're differentiating between columns where the contents are usually one item in an array (short-array) and other arrays (array). This is so we can display shorter array values in a more readable fashion, whereas longer arrays are potentially easier to "read" & compare if we just display the number of items in each array. https://github.com/githubocto/flat-ui/blob/main/src/store.ts#L813-L831

Let me know if any of that didn't make sense!

nikodraca commented 2 years ago

So if I understand correctly the idea was that arrays really meant to be filtered by length and less by the contents?

Follow up q: couldn't we consolidate categories and short-arrays?

Wattenberger commented 2 years ago

hmm, potentially. They wouldn't automatically be categories, but could be passed further down and treated the same as columns of strings: https://github.com/githubocto/flat-ui/blob/main/src/store.ts#L688

I'm a bit hesitant to do more "magic" handling of data, though! The farther we get from the raw data, the less reliable the table view gets. There is the possibility to treat items within array values are rendered as pills, similar to category values, which is perhaps what you're getting at. In that case, I think the path forward would be to have a multiselect filter, and to change the render component for arrays.

nikodraca commented 2 years ago

Ok cool, thanks for answering all my questions 😄

nikodraca commented 2 years ago

Hey @Wattenberger 👋 wanted to share some progress and get some feedback: https://user-images.githubusercontent.com/3537270/154796985-ab232baa-1a24-4cef-991b-7c06208c6794.mov

What's New:

Questions:

nikodraca commented 2 years ago

Hey @Wattenberger 😄 just wanted to check in on this, really eager to get the ball rolling!

nikodraca commented 2 years ago

Hey @Wattenberger sorry to bother again, I'd love to get some eyes on this! Is there someone on the team you could put me in touch with?

Wattenberger commented 2 years ago

hey Niko! sorry about the delay! I was moving cross-country and now the team is heads-down on a launch. I'll try to get to this within the next week!

nikodraca commented 2 years ago

No worries at all! Hope the move went well 😄

Wattenberger commented 2 years ago

okay! this is looks great, thanks for the progress! A few tiny suggestions:

I'm thinking of instead counting how many rows have that category from originalData instead of filteredData. Does that make sense? Makes total sense!

great progress so far!

nikodraca commented 2 years ago

great progress so far!

I got a new MacBook this week and didn't push changes before I wiped it 🙃 looks like I'll be starting from scratch, but thank you for the comments! Talk soon

Wattenberger commented 2 years ago

Ah super frustrating! Good luck re-building those changes!