Skip to content

feat(search-query-builder): Remove default values for number based filters - #129334

Closed
sentry-junior[bot] wants to merge 9 commits into
masterfrom
nd/remove-numeric-filter-default-values
Closed

sentry-junior[bot] wants to merge 9 commits into
masterfrom
nd/remove-numeric-filter-default-values

Conversation

@sentry-junior

@sentry-junior sentry-junior Bot commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

New number based filters (numeric, integer, currency, duration, size, percentage, and their aggregates) now start without a value, e.g. span.duration:>, instead of being pre-filled with 100, 10ms, 10bytes, etc. Previously the example value was committed into the query as soon as the filter was added, so results were filtered by a value the user never picked.

No grammar or API changes. Neither the frontend nor the backend grammar can write an empty number filter (key:> parses as an invalid text filter or free text in both). Instead of changing that, the builder keeps the incomplete filter out of the committed query:

  • useQueryBuilderState tracks a pendingFilterKey. The draft query still holds the filter with its placeholder value, so the chip, operator menu and token-location logic work unchanged.
  • While a filter is pending, committedQuery never includes it. onChange, onSearch and the API only see the filter once a value is entered or the user leaves the filter. Pressing Enter in the free text input searches the committed query while a filter is pending.
  • The chip shows an empty value, the value input starts empty (the old default stays as the input placeholder), and the row label leaves the value out. If the operator changes to "is", the placeholder isn't treated as a selected value.
  • The filter stays pending while the user changes its key, operator or aggregate arguments. None of these commit the query, so the previous search stays in place (no dangling OR from removing the pending filter), and changing the key or operator returns focus to the value. Closing the key editor without a change (same key, Escape, or an empty key) also returns focus to the value; only blurring it counts as leaving the filter.
  • Leaving the filter without a value commits it with the placeholder value (e.g. span.duration:>10ms): Escape or Enter with an empty input, focus moving outside the filter, or blurring with an invalid value that gets rejected. Undo skips the pending state.
  • The filter's remove (X) button and the search bar's "Clear search query" button act on pointer down while a filter is pending. Otherwise the press moves focus out of the filter first: the remove click could miss the button and leave an empty filter behind, and clearing committed the placeholder value and ran an extra search before the query was cleared. The remove button ignores the click that follows such a press, because the positional item key means the button is reused for the next filter.

Dashboard global filters call getInitialFilterText directly and are unchanged.

Things to look at:

  • Pending is tracked by positional item key (filter:N). After each action the reducer finds the filter again by the unchanged text before or after it. That covers the normal flows, but I'd like a second look at it.
  • Leaving the filter is detected with a deferred focus check, because the operator menu moves focus out of the chip and back.
  • Specs that used {Escape} to accept the default value still pass as on master. Specs that check the chip right after adding a filter now expect an empty value.

via Nick.

--

View Session [Sentry]

…lters

New numeric, duration, size, percentage and currency filters (including
aggregates) now start with an empty value instead of a placeholder such as
100 or 10ms, so the search isn't filtered by a value the user didn't pick.

The grammar accepts an empty value for number based filters, e.g.
`span.duration:>`, and the frontend parser marks those filters as
FILTER_MUST_HAVE_VALUE, which the builder already tolerates while the value
menu is open. Dashboard global filters keep their example values.

Co-Authored-By: Nicholas Deschenes <nicholas.deschenes@sentry.io>
@github-actions github-actions Bot added the Scope: Frontend Automatically applied to PRs that change frontend components label Oct 30, 2026
@github-actions

github-actions Bot commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

📊 Type Coverage Diff

✅ no issues found

Rework the change so the search grammars stay as they are. A new
number-based filter now starts without a value, but its placeholder
value only lives in the builder's draft query. It is never committed,
so onChange, onSearch and the API never see it. Entering a value
commits the filter as usual, and leaving the filter without a value
removes it.

This reverts the grammar, parser and dashboard changes from the
previous commit.

Co-Authored-By: Nicholas Deschenes <nicholas.deschenes@sentry.io>
… number filter

Leaving a new number filter without a value now commits it with its
example value instead of removing it.

Co-Authored-By: Nicholas Deschenes <nicholas.deschenes@sentry.io>
…tton is pressed

Pressing the remove button closes the empty filter's value editor first, and
the click could miss the button. The filter was left behind without a value
and got the placeholder value on blur.

Co-Authored-By: Nicholas Deschenes <nicholas.deschenes@sentry.io>
…ng filter

Pressing the clear button moved focus out of an empty number filter first,
which committed its placeholder value and ran a search before the query was
cleared.

Co-Authored-By: Nicholas Deschenes <nicholas.deschenes@sentry.io>
@github-actions

github-actions Bot commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

Story previews

Preview the stories changed in this PR on the Vercel deployment:

Preview deployment: https://sentry-54skx00tq.sentry.dev

sentry-junior Bot and others added 2 commits November 2, 2026 16:47
- Removing a pending filter on press no longer also removes the next filter,
  which reuses the remove button through positional item keys.
- Changing a pending filter's operator to "is" no longer keeps its
  placeholder value as a selected value.
- Rejecting an invalid value on blur marks the value editor closed, so the
  pending filter gets its placeholder value instead of staying empty.
- Searching from the free text input uses the committed query while a
  filter is pending.

Co-Authored-By: Nicholas Deschenes <nicholas.deschenes@sentry.io>
After an invalid value is rejected and the pending filter commits its
placeholder, searching from the input uses the value the filter shows.

Co-Authored-By: Nicholas Deschenes <nicholas.deschenes@sentry.io>
… changes

Changing the key of a number filter without a value to another key of the
same type committed the query and closed the key editor without returning
focus to the filter. Committing removed the pending filter from the query
and could leave a dangling Boolean operator (`OR device:foo`), and the
focus loss then committed the placeholder value.

While the filter is pending, the key change no longer commits the query and
returns focus to the value editor, like an operator change does.

Co-Authored-By: Nicholas Deschenes <nicholas.deschenes@sentry.io>
…e key editor closes

Selecting the same key, pressing Escape, or committing an empty key input
closed the key editor of a number filter without a value and moved focus
out of the filter, which committed its placeholder value.

Every key editor close except blur now sends focus back to the pending
filter's value through a new SET_FOCUS_OVERRIDE action, which also replaces
the focus override added to UPDATE_FILTER_KEY.

Co-Authored-By: Nicholas Deschenes <nicholas.deschenes@sentry.io>
@nsdeschenes

Copy link
Copy Markdown
Contributor

Closing out as this is a bloated implementation now. Gonna go with #129535 instead.

@nsdeschenes nsdeschenes closed this Nov 2, 2026

This branch was successfully deployed

1 active deployment
Preview — b059dbda Deployed Nov 2, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Scope: Frontend Automatically applied to PRs that change frontend components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant