CloudCannon / pagefind

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

Type of input in `PagefindUI` filters: `checkbox` vs `radio` #590

Closed nhoizey closed 2 months ago

nhoizey commented 3 months ago

PagefindUI currently generates <input type="checkbox"> for filters values.

But I couldn't find how to allow users to check multiple values in the same filter group. Is it supposed to be possible? It would be great.

If it isn't (unfortunately), could the <input type="checkbox"> be replaced with <input type="radio">?

bglw commented 3 months ago

Hmm, the default UI filters are multi-selectable. Is that not what you're seeing?

Ref: https://xkcd.pagefind.app/

Screenshot 2024-04-04 at 6 24 57 PM

checkbox is indeed the multiselect case — radio inputs would force single selection.

nhoizey commented 3 months ago

Ok, I understand what's happening, I misunderstood what means “Currently, the Default UI treats all filters as “AND” filters, meaning pages will only be shown if they match all toggled filters.

The tests I did were on filter groups where contents can have only one value, so when I select a value, the other disappear.

For example on https://nicolas-hoizey.photo/search/?q=cla

If I check the “Page type” filter value “Gear”, I don't see anymore values “Gallery” and “Photo”.

I thought I would be able to select both “Gear” and “Gallery” for example. I thought the “AND” applied only between filter values from different groups.

For example, that I could see result that match (“Gear” OR “Gallery”) AND (“America” OR “Africa”).

It would be great, but now I understand it's not possible.

Should I keep this issue open, or maybe create a new one asking for such a feature?

bglw commented 3 months ago

A new one would be good — the filtering logic for (“Gear” OR “Gallery”) AND (“America” OR “Africa”) exists in the API, but neither UI frontend currently has a way to construct custom compound filters.

In general, pushing forward filtering is more likely to land in the Modular UI than in the currently-default UI. In saying that, adding a simple option to the Default UI that changes all filter values from AND to OR is possibly easy enough.

nhoizey commented 2 months ago

New issue: