Skip to content

AdHocFiltersVariable: clear origin filters to =| All when multi-value operators are supported - #1603

Draft
samjewell wants to merge 4 commits into
mainfrom
sj/clear-origin-filters-to-all
Draft

AdHocFiltersVariable: clear origin filters to =| All when multi-value operators are supported#1603
samjewell wants to merge 4 commits into
mainfrom
sj/clear-origin-filters-to-all

Conversation

@samjewell

Copy link
Copy Markdown
Contributor

Fixes #1602. Stacked on #1591 (base branch is sj/adhoc-default-filters-all-option) - the diff shows only the delta. Could equally be folded into #1591 as one more commit; draft until we decide.

Problem

Clearing (X) a dashboard-origin filter rewrites it to the legacy regex match-all (=~ / .*), which is deliberately passed through to panel queries. That is neutral only for datasources with Prometheus-style regex semantics. Non-regex datasources misinterpret it - e.g. the Cube datasource maps =~ to equals, so the cleared state becomes WHERE x = '.*' and every panel shows No data while the pill reads "All".

Change

In updateToMatchAll, when the variable has supportsMultiValueOperators, clear to the all-value sentinel (operator: '=|', value $__all) introduced by #1591 - the exact state selecting "All" in the combobox produces. It is stripped from queries in DrilldownDependenciesManager.getFilters() before any datasource sees it: neutral by construction, regardless of the datasource's regex semantics.

Gating rationale:

All clear paths route through updateToMatchAll (pill X, combobox backspace, committing an emptied multi-value selection), so one branch covers them all. Restore is unaffected: originalValueKey is keyed on key::origin, not operator - covered in the new test.

Tests

  • New: clearing with supportsMultiValueOperators: true yields =| $__all / valueLabels: ['All'] / restorable: true, and restore returns the original values.
  • Existing match-all tests (default state, no multi-value support) pass unchanged - the legacy path is preserved.
  • Full adhoc + DrilldownDependenciesManager + SceneQueryRunner suites: 669/669.

samjewell and others added 4 commits July 30, 2026 15:32
Origin (default) filters with the 'one of' operator now offer an explicit
All option in the multi-value dropdown, like query variables. Selecting it
stores the special $__all value; such filters keep their pill (labelled
All) but are excluded from query requests, the filter expression, and
getTagKeys/getTagValues lookups, so they no longer restrict results.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
… All label

- isAllValueFilter now requires the one-of operator, so a literal
  $__all value on any other operator keeps filtering instead of being
  silently dropped from queries and lookups
- getFilterValueByKey applies the same predicate, so per-key
  interpolation no longer returns the literal sentinel
- The prepended All row now takes the initial highlight (and again when
  the input is cleared), keeping keyboard indices valid when the first
  fetched option is a group header
- Pill labels are paired with values, so the sentinel always renders
  with the current All translation rather than a persisted label

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…n multi-value operators are supported

Clearing (X) a dashboard-origin filter rewrote it to the legacy regex
match-all ('=~' / '.*'), which is passed through to panel queries and is
only neutral for datasources with Prometheus-style regex semantics -
non-regex datasources (e.g. Cube, SQL-backed) misinterpret it and every
panel shows No data while the pill reads All.

When the variable supports multi-value operators, clear to the all-value
sentinel instead (operator '=|', value $__all) - the same state
selecting All in the combobox produces. It is stripped from queries
before any datasource sees it, so it is neutral by construction.

Variables without multi-value operator support (Prometheus, Loki - which
do not declare multiValueFilterOperators) keep the existing '=~ .*'
behaviour: the cleared state must be an operator the user could have
picked themselves.

Covers all clear paths: pill X, combobox backspace, and committing an
emptied multi-value selection, which all route through updateToMatchAll.

Fixes #1602

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@samjewell samjewell self-assigned this Aug 7, 2026
Base automatically changed from sj/adhoc-default-filters-all-option to main August 18, 2026 15:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant