CloudCannon / pagefind

Static low-bandwidth search at scale
https://pagefind.app
MIT License
3.45k stars 111 forks source link

feature request: a way hide filters which do not reduce results #475

Open olets opened 12 months ago

olets commented 12 months ago

My expectation: checking a filter checkbox always filters out some hits. Only filters that can reduce the displayed hits are displayed.

Actual: if every displayed hit has the filter x[y], the filter panel shows the filter y under the filter group x. (Appropriately checking the filter checkbox does not result in any hits being filtered out.)

Solution ideas:

bglw commented 11 months ago

Hey @olets 👋

I don't think I'd want it as a default personally, but it does sound like a good fit for an option. It's come up once before, and there are some quirks that I can think of that would need to be considered. For example, you wind up in situations where unchecking a filter might make it immediately disappear, or possibly situations where filters are enabled but hidden.

Anything is solvable so I think it would be worth tackling 🙂

As with most current UI proposals, I'm inclined to push this to the Modular UI that will eventually be the recommended starting point for Pagefind. In this world, a different filter component could be made instead, targeting this refinement style.

If anyone reading this does want to contribute it as a feature to the Default UI in the meantime, I'm happy to give some pointers and review code 🙂

(If it unblocks you and you think you can make it work, adding a data attribute with the remaining result count would be an easy lift that I could do, let me know if you think that's the best path)

olets commented 11 months ago

If it unblocks you and you think you can make it work, adding a data attribute with the remaining result count would be an easy lift that I could do, let me know if you think that's the best path

Don't spend time on that on my account. I think we'd need the bigger lift of an "if you check this box, n results that are currently visible will disappear" attribute value. I haven't looked under the hood, but I can imagine that getting tricky for performance.

Plus I'm not blocked. I'm using PageFind on a small site where it's common to have two or three results total, all with two or three shared filter values. The "filters that don't filter" effect is noticeable to me, but it does no harm and I'm not concerned that it'll hurt users' experience.

the Modular UI

Cool I hadn't seen that.

If anyone reading this does want to contribute it as a feature to the Default UI in the meantime, I'm happy to give some pointers and review code

Hmmmm I'm currently shifting to spend more time on non-computer things, but it's hard to resist checking out a new project 🙂 Don't hold your breath but maybe I'll be back!