@@ -37,7 +37,6 @@ import ROUTES from '@src/ROUTES';
37
37
import SCREENS from '@src/SCREENS' ;
38
38
import type Report from '@src/types/onyx/Report' ;
39
39
import isLoadingOnyxValue from '@src/types/utils/isLoadingOnyxValue' ;
40
- import KeyboardUtils from '@src/utils/keyboard' ;
41
40
import { getQueryWithSubstitutions } from './getQueryWithSubstitutions' ;
42
41
import type { SubstitutionMap } from './getQueryWithSubstitutions' ;
43
42
import { getUpdatedSubstitutionsMap } from './getUpdatedSubstitutionsMap' ;
@@ -74,9 +73,10 @@ function getContextualSearchQuery(item: SearchQueryItem) {
74
73
type SearchRouterProps = {
75
74
onRouterClose : ( ) => void ;
76
75
shouldHideInputCaret ?: TextInputProps [ 'caretHidden' ] ;
76
+ isSearchRouterDisplayed ?: boolean ;
77
77
} ;
78
78
79
- function SearchRouter ( { onRouterClose, shouldHideInputCaret} : SearchRouterProps , ref : React . Ref < View > ) {
79
+ function SearchRouter ( { onRouterClose, shouldHideInputCaret, isSearchRouterDisplayed } : SearchRouterProps , ref : React . Ref < View > ) {
80
80
const { translate} = useLocalize ( ) ;
81
81
const styles = useThemeStyles ( ) ;
82
82
const [ , recentSearchesMetadata ] = useOnyx ( ONYXKEYS . RECENT_SEARCHES ) ;
@@ -113,6 +113,10 @@ function SearchRouter({onRouterClose, shouldHideInputCaret}: SearchRouterProps,
113
113
return undefined ;
114
114
}
115
115
116
+ if ( ! isSearchRouterDisplayed ) {
117
+ return undefined ;
118
+ }
119
+
116
120
const reportForContextualSearch = recentReports . find ( ( option ) => option . reportID === contextualReportID ) ;
117
121
if ( ! reportForContextualSearch ) {
118
122
return undefined ;
@@ -159,7 +163,7 @@ function SearchRouter({onRouterClose, shouldHideInputCaret}: SearchRouterProps,
159
163
} ,
160
164
] ;
161
165
} ,
162
- [ contextualReportID , styles . activeComponentBG , textInputValue , translate ] ,
166
+ [ contextualReportID , styles . activeComponentBG , textInputValue , translate , isSearchRouterDisplayed ] ,
163
167
) ;
164
168
165
169
const searchQueryItem = textInputValue
@@ -270,14 +274,11 @@ function SearchRouter({onRouterClose, shouldHideInputCaret}: SearchRouterProps,
270
274
}
271
275
} else {
272
276
onRouterClose ( ) ;
273
-
274
- KeyboardUtils . dismiss ( ) . then ( ( ) => {
275
- if ( item ?. reportID ) {
276
- Navigation . navigateToReportWithPolicyCheck ( { reportID : item ?. reportID } ) ;
277
- } else if ( 'login' in item ) {
278
- navigateToAndOpenReport ( item . login ? [ item . login ] : [ ] , false ) ;
279
- }
280
- } ) ;
277
+ if ( item ?. reportID ) {
278
+ Navigation . navigateToReportWithPolicyCheck ( { reportID : item ?. reportID } ) ;
279
+ } else if ( 'login' in item ) {
280
+ navigateToAndOpenReport ( item . login ? [ item . login ] : [ ] , false ) ;
281
+ }
281
282
}
282
283
} ,
283
284
[ autocompleteSubstitutions , onRouterClose , onSearchQueryChange , submitSearch , textInputValue ] ,
0 commit comments