Skip to content

feat(search): Switch filter operator from contains to is on dropdown selection#111668

Merged
nsdeschenes merged 6 commits into
masterfrom
nd/chore-search-query-builder-switch-to-is-when-selecting-value
Mar 31, 2026
Merged

feat(search): Switch filter operator from contains to is on dropdown selection#111668
nsdeschenes merged 6 commits into
masterfrom
nd/chore-search-query-builder-switch-to-is-when-selecting-value

Conversation

@nsdeschenes

@nsdeschenes nsdeschenes commented Mar 26, 2026

Copy link
Copy Markdown
Contributor

Tweaking the logic around selecting default operators. When a user selects a value from the dropdown it's likely they're looking for an exact matching value, rather than it containing that value.

This PR modifies the query builder logic so that if a user selects a value from the value combobox it'll change it from contains to is. However, if a user already has a valid contains filter, we do not change the operator if selecting a value afterwards.

Example:

Screen.Recording.2026-03-26.at.16.11.46.mov

nsdeschenes and others added 2 commits March 26, 2026 15:15
… action

Extend modifyFilterValue and the UPDATE_TOKEN_VALUE reducer action to
accept an optional operator parameter. When provided, the entire filter
token is replaced atomically to update both value and operator in a
single dispatch, avoiding stale token location issues.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
When a user selects a value from the filter value combobox dropdown,
the operator now switches from "contains" to "is". Free-text input
continues to use the "contains" operator. For negated filters, "does
not contain" switches to "is not" on dropdown selection.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@github-actions github-actions Bot added the Scope: Frontend Automatically applied to PRs that change frontend components label Mar 26, 2026
Comment thread static/app/components/searchQueryBuilder/hooks/useQueryBuilderState.tsx Outdated
…e operators in modifyFilterValue

The internalOp mapping in modifyFilterValue was missing cases for
DOES_NOT_START_WITH and DOES_NOT_END_WITH. These operators were handled
by the negated flag check above, but the else branch fell through and
assigned the raw negative operator as internalOp, producing an invalid
replacement string.

Add the missing mappings to match the behaviour already present in the
companion function modifyFilterOperatorQuery.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@nsdeschenes nsdeschenes marked this pull request as ready for review March 26, 2026 19:57
@nsdeschenes nsdeschenes requested a review from a team as a code owner March 26, 2026 19:57
When a user selects a value from the dropdown, the operator was
unconditionally switching from 'contains' to 'is'. This should only
happen when the filter has no existing value (i.e. the user is picking
their first value on a new filter token).

Check token.value.value instead of token.value.text to detect an empty
value, since token.value.text is '""' (truthy) for a newly created
empty filter while token.value.value is '' (falsy).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Comment thread static/app/components/searchQueryBuilder/tokens/filter/valueCombobox.tsx Outdated
…ator switch

Add a type guard (token.value.type === Token.VALUE_TEXT) before
accessing token.value.value to satisfy TypeScript and avoid accessing
the property on incompatible value token variants.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

@cursor cursor Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Comment thread static/app/components/searchQueryBuilder/hooks/useQueryBuilderState.tsx Outdated
…e duplicated operator mapping

The negated/internalOp mapping from TermOperator existed identically in both
modifyFilterOperatorQuery and modifyFilterValue. Consolidate into a single helper.

@wmak wmak left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@nsdeschenes nsdeschenes merged commit 9b4d18d into master Mar 31, 2026
70 checks passed
@nsdeschenes nsdeschenes deleted the nd/chore-search-query-builder-switch-to-is-when-selecting-value branch March 31, 2026 18:24
dashed pushed a commit that referenced this pull request Apr 1, 2026
…selection (#111668)

Tweaking the logic around selecting default operators. When a user
selects a value from the dropdown it's likely they're looking for an
exact matching value, rather than it containing that value.

This PR modifies the query builder logic so that if a user selects a
value from the value combobox it'll change it from `contains` to `is`.
However, if a user already has a valid contains filter, we do not change
the operator if selecting a value afterwards.

---------

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
@github-actions github-actions Bot locked and limited conversation to collaborators Apr 16, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Scope: Frontend Automatically applied to PRs that change frontend components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants