@@ -15,6 +15,7 @@ import { isSubscriptionPaid } from '../../../../plus/gk/utils/subscription.utils
1515import type { LaunchpadCommandArgs } from '../../../../plus/launchpad/launchpad' ;
1616import { createCommandLink } from '../../../../system/commands' ;
1717import { debounce } from '../../../../system/decorators/debounce' ;
18+ import { debounce as debounceFunc } from '../../../../system/function/debounce' ;
1819import { createWebviewCommandLink } from '../../../../system/webview' ;
1920import type {
2021 GraphExcludedRef ,
@@ -38,7 +39,6 @@ import {
3839 UpdateIncludedRefsCommand ,
3940 UpdateRefsVisibilityCommand ,
4041} from '../../../plus/graph/protocol' ;
41- import type { CustomEventType } from '../../shared/components/element' ;
4242import type { RadioGroup } from '../../shared/components/radio/radio-group' ;
4343import type { GlSearchBox } from '../../shared/components/search/search-box' ;
4444import type { SearchNavigationEventDetail } from '../../shared/components/search/search-input' ;
@@ -323,9 +323,11 @@ export class GlGraphHeader extends SignalWatcher(LitElement) {
323323 this . onRefIncludesChanged ( $el . value as GraphBranchesVisibility ) ;
324324 }
325325
326- @debounce ( 250 )
327326 async handleSearch ( ) {
328327 this . appState . searching = this . searchValid ;
328+ if ( ! this . searchValid ) {
329+ this . appState . searchResultsResponse = undefined ;
330+ }
329331 try {
330332 const rsp = await this . _ipc . sendRequest ( SearchRequest , {
331333 search : this . searchValid ? { ...this . appState . filter } : undefined /*limit: options?.limit*/ ,
@@ -336,17 +338,19 @@ export class GlGraphHeader extends SignalWatcher(LitElement) {
336338 }
337339
338340 this . appState . searchResultsResponse = rsp . results ;
339- this . appState . selectedRows = rsp . selectedRows ;
341+ if ( rsp . selectedRows != null ) {
342+ this . appState . selectedRows = rsp . selectedRows ;
343+ }
340344 } catch {
341345 this . appState . searchResultsResponse = undefined ;
342346 }
343347 this . appState . searching = false ;
344348 }
345349
346- private handleSearchInput = ( e : CustomEvent < SearchQuery > ) => {
350+ private handleSearchInput ( e : CustomEvent < SearchQuery > ) {
347351 this . appState . filter = e . detail ;
348352 void this . handleSearch ( ) ;
349- } ;
353+ }
350354
351355 private async onSearchPromise ( search : SearchQuery , options ?: { limit ?: number ; more ?: boolean } ) {
352356 try {
@@ -356,7 +360,9 @@ export class GlGraphHeader extends SignalWatcher(LitElement) {
356360 more : options ?. more ,
357361 } ) ;
358362 this . appState . searchResultsResponse = rsp . results ;
359- this . appState . selectedRows = rsp . selectedRows ;
363+ if ( rsp . selectedRows != null ) {
364+ this . appState . selectedRows = rsp . selectedRows ;
365+ }
360366 return rsp ;
361367 } catch {
362368 return undefined ;
@@ -1038,8 +1044,9 @@ export class GlGraphHeader extends SignalWatcher(LitElement) {
10381044 errorMessage=${ this . appState . searchResultsError ?. error ?? '' }
10391045 ?resultsHidden=${ this . appState . searchResultsHidden }
10401046 ?resultsLoaded=${ this . appState . searchResults != null }
1041- @gl-search-inputchange=${ ( e : CustomEventType < 'gl-search-inputchange' > ) =>
1042- this . handleSearchInput ( e ) }
1047+ @gl-search-inputchange=${ debounceFunc ( this . handleSearchInput . bind ( this ) , 250 ) as (
1048+ e : CustomEvent < SearchQuery > ,
1049+ ) => void }
10431050 @gl-search-navigate=${ this . handleSearchNavigation }
10441051 @gl-search-openinview=${ this . onSearchOpenInView }
10451052 @gl-search-modechange=${ this . handleSearchModeChanged }
0 commit comments