@@ -31,7 +31,11 @@ import {
3131} from 'sentry/components/searchQueryBuilder/tokens/filterKeyListBox/utils' ;
3232import { itemIsSection } from 'sentry/components/searchQueryBuilder/tokens/utils' ;
3333import type { FieldDefinitionGetter } from 'sentry/components/searchQueryBuilder/types' ;
34- import type { Token , TokenResult } from 'sentry/components/searchSyntax/parser' ;
34+ import type {
35+ ParseResultToken ,
36+ Token ,
37+ TokenResult ,
38+ } from 'sentry/components/searchSyntax/parser' ;
3539import { getKeyName } from 'sentry/components/searchSyntax/utils' ;
3640import type { RecentSearch , TagCollection } from 'sentry/types/group' ;
3741import { trackAnalytics } from 'sentry/utils/analytics' ;
@@ -130,7 +134,9 @@ function useFilterKeyItems() {
130134
131135function useFilterKeySections ( {
132136 recentSearches,
137+ filterItem,
133138} : {
139+ filterItem : Node < ParseResultToken > ;
134140 recentSearches : RecentSearch [ ] | undefined ;
135141} ) {
136142 const { filterKeySections, query, disallowLogicalOperators} = useSearchQueryBuilder ( ) ;
@@ -149,20 +155,22 @@ function useFilterKeySections({
149155 return [ ] ;
150156 }
151157
158+ const isFirstItem = filterItem . key . toString ( ) . endsWith ( ':0' ) ;
152159 if ( recentSearches ?. length && ! query ) {
153160 const recentSearchesSections : Section [ ] = [
154161 RECENT_SEARCH_CATEGORY ,
155162 ALL_CATEGORY ,
156163 ...definedSections ,
157164 ] ;
158- if ( ! disallowLogicalOperators && hasConditionalsInCombobox ) {
165+
166+ if ( ! disallowLogicalOperators && ! isFirstItem && hasConditionalsInCombobox ) {
159167 recentSearchesSections . push ( BOOLEAN_CATEGORY ) ;
160168 }
161169 return recentSearchesSections ;
162170 }
163171
164172 const customSections : Section [ ] = [ ALL_CATEGORY , ...definedSections ] ;
165- if ( ! disallowLogicalOperators && hasConditionalsInCombobox ) {
173+ if ( ! disallowLogicalOperators && ! isFirstItem && hasConditionalsInCombobox ) {
166174 customSections . push ( BOOLEAN_CATEGORY ) ;
167175 }
168176
@@ -171,6 +179,7 @@ function useFilterKeySections({
171179 disallowLogicalOperators ,
172180 filterKeySections ,
173181 hasConditionalsInCombobox ,
182+ filterItem . key ,
174183 query ,
175184 recentSearches ?. length ,
176185 ] ) ;
@@ -196,7 +205,12 @@ const conditionalFilterItems = [
196205 createBooleanFilterItem ( { value : 'OR' } ) ,
197206] ;
198207
199- export function useFilterKeyListBox ( { filterValue} : { filterValue : string } ) {
208+ interface UseFilterKeyListBoxArgs {
209+ filterItem : Node < ParseResultToken > ;
210+ filterValue : string ;
211+ }
212+
213+ export function useFilterKeyListBox ( { filterValue, filterItem} : UseFilterKeyListBoxArgs ) {
200214 const {
201215 filterKeys,
202216 getFieldDefinition,
@@ -212,6 +226,7 @@ export function useFilterKeyListBox({filterValue}: {filterValue: string}) {
212226 const { data : recentSearches } = useRecentSearches ( ) ;
213227 const { sections, selectedSection, setSelectedSection} = useFilterKeySections ( {
214228 recentSearches,
229+ filterItem,
215230 } ) ;
216231
217232 const organization = useOrganization ( ) ;
0 commit comments