Change behavior of multiple filters within a single facet#2
Open
brockfanning wants to merge 2 commits into
Open
Change behavior of multiple filters within a single facet#2brockfanning wants to merge 2 commits into
brockfanning wants to merge 2 commits into
Conversation
…ts that are an intersection of filters, rather than a union. Also add option to hide all empty filters (since they are now useless to display).
… changing 'intersection' to 'intersect'
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The current behavior for multiple filters in a single facet is not what I would expect. The result set is a union of the active filters, instead of an intersection. For example in the demo, if I click on "Erlang", I see 9 results as advertised. The "Lisp" filter then advertises that it has only 1 result, since there is only 1 item that is tagged both "Erlang" and "Lisp". So far this is what I would expect. But if I click on "Lisp", the result set now includes 15 items, and the "Lisp" filter count changes to 7.
The behavior I was expecting was 1 item in the result set, and both "Erlang" and "Lisp" counts changing to 1. This is actually the behavior when selecting multiple filters across different facets, so I was thinking that it should probably work the same for multiple filters in a single facet. This is especially important for sites that have only one facet, like a single "tags" taxonomy or something.
My patch changes this behavior. It also removes the code that was changing all zero-counts into plus-signs, since now the "0" actually makes sense. However, the displaying of the empty filters is essentially useless, since clicking on it only reduces the search results to 0. So I've added an option to hide empty filters, and set its default to true.
Thanks for a great script, and hope this is helpful!