Fix duplicated query when using a toggle after switching search modes
Created by: lguychard
Fixes #9407
Review by commit.
A better fix here might be to model query state in a way that would make invalid states impossible: having non-empty filtersInQuery
state while in plain text mode is an invalid state. We could avoid this by removing the individual interactiveSearchMode
, filtersInQuery
state members in favour of an union like this:
type QueryState =
| {
mode: 'plaintext'
query: string
cursorPosition: number
}
| {
mode: 'interactive'
filters: FiltersToTypeAndValue
searchPattern: string
}
This doesn't solve the pain point of nested components having to know about the search mode when they want to update the query (see https://github.com/sourcegraph/sourcegraph/pull/9225#discussion_r400034693)
cc @attfarhan