Commit Graph
1 Commits
Author SHA1 Message Date
Lauri Ojansivu b13a5af330 Add a three-state label filter: unfiltered -> include -> exclude -> clear.
#2886: clicking a label filter chip only ever toggled between unfiltered
and filtering FOR that label. Filter.labelIds now has a companion
Filter.excludedLabelIds SetFilter (same API/shape), and a new
Filter.toggleLabelFilter(labelId) cycles a label through three states:
not in either set -> added to labelIds (include) -> moved to
excludedLabelIds (exclude) -> removed (back to unfiltered).
Filter._getMongoSelector() merges the exclusion into the existing
labelIds selector ({$in, $nin}) rather than a separate ignored key, so a
card carrying an excluded label is filtered out even when it also
matches an included label - exclusion wins over inclusion. An
exclude-only filter (no included label) is also handled: isActive() and
the filterSelector-push condition both check excludedLabelIds, and
reset() clears it too.

sidebarFilters.js's 'click .js-toggle-label-filter' handler now calls
Filter.toggleLabelFilter() for a real label chip, keeping the existing
plain two-state Filter.labelIds.toggle() only for the special "no label"
pseudo-entry (data-filter-id="__none__"), which is out of scope for this
three-state cycle. sidebarFilters.jade gives an excluded chip a distinct
"excluded" class (struck-through text via sidebar.css) plus a fa-ban icon
tooltipped with the new filter-label-excluded i18n key, alongside the
existing fa-check used for an included chip.

Scoped to labels only, matching the issue's exact wording - members, due
dates and the other filter types keep their existing two-state toggle in
this pass; the same three-state treatment could be added to them later if
wanted.

tests/labelFilterThreeState.test.cjs drives the real client/lib/filter.js
under plain `node` (via tests/helpers/meteorStubLoader.mjs, an ESM loader
hook stubbing only the Meteor packages/modules filter.js imports) rather
than reimplementing the logic, and pins: the exact three-click cycle in
order (unfiltered -> included -> excluded -> unfiltered), that the cycle
repeats and that two labels cycle independently, and the card-matching
predicate - an excluded-only card is filtered out, an excluded label
wins over an included one on the same card, and an exclude-only filter
(nothing included) still filters correctly.

Thanks to bennyandresen and xet7 !

Closes #2886,
2026-09-10 20:35:40 +03:00