From 235ecb6b72a9244f6bf3988e1730f51eb97da43d Mon Sep 17 00:00:00 2001 From: thelullabyy Date: Fri, 2 May 2025 15:44:24 +0700 Subject: [PATCH 1/2] fix: cmd+K navigation fails to open chat desktop --- src/components/Search/SearchAutocompleteList.tsx | 10 +++++++++- src/components/Search/SearchRouter/SearchRouter.tsx | 1 + 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/components/Search/SearchAutocompleteList.tsx b/src/components/Search/SearchAutocompleteList.tsx index 9065ed916ba5..26176f9ba481 100644 --- a/src/components/Search/SearchAutocompleteList.tsx +++ b/src/components/Search/SearchAutocompleteList.tsx @@ -5,6 +5,7 @@ import {useOnyx} from 'react-native-onyx'; import * as Expensicons from '@components/Icon/Expensicons'; import {usePersonalDetails} from '@components/OnyxProvider'; import {useOptionsList} from '@components/OptionListContextProvider'; +import type {AnimatedTextInputRef} from '@components/RNTextInput'; import SelectionList from '@components/SelectionList'; import SearchQueryListItem, {isSearchQueryItem} from '@components/SelectionList/Search/SearchQueryListItem'; import type {SearchQueryItem, SearchQueryListItemProps} from '@components/SelectionList/Search/SearchQueryListItem'; @@ -77,6 +78,9 @@ type SearchAutocompleteListProps = { /** Callback to highlight (e.g. scroll to) the first matched item in the list. */ onHighlightFirstItem?: () => void; + + /** Ref for textInput */ + textInputRef: React.RefObject; }; const defaultListOptions = { @@ -135,8 +139,9 @@ function SearchAutocompleteList( onListItemPress, setTextQuery, updateAutocompleteSubstitutions, - shouldSubscribeToArrowKeyEvents, + shouldSubscribeToArrowKeyEvents = true, onHighlightFirstItem, + textInputRef, }: SearchAutocompleteListProps, ref: ForwardedRef, ) { @@ -589,6 +594,9 @@ function SearchAutocompleteList( onLayout={() => { setPerformanceTimersEnd(); setIsInitialRender(false); + if (!!textInputRef.current && ref && 'current' in ref) { + ref.current?.updateExternalTextInputFocus?.(textInputRef.current.isFocused()); + } }} showScrollIndicator={!shouldUseNarrowLayout} sectionTitleStyles={styles.mhn2} diff --git a/src/components/Search/SearchRouter/SearchRouter.tsx b/src/components/Search/SearchRouter/SearchRouter.tsx index 6295c64ca7e9..faa87252decd 100644 --- a/src/components/Search/SearchRouter/SearchRouter.tsx +++ b/src/components/Search/SearchRouter/SearchRouter.tsx @@ -366,6 +366,7 @@ function SearchRouter({onRouterClose, shouldHideInputCaret, isSearchRouterDispla updateAutocompleteSubstitutions={updateAutocompleteSubstitutions} onHighlightFirstItem={() => listRef.current?.updateAndScrollToFocusedIndex(1)} ref={listRef} + textInputRef={textInputRef} /> )} From 4374b36839501e21f655b035b562eae91209522b Mon Sep 17 00:00:00 2001 From: thelullabyy Date: Fri, 2 May 2025 15:52:19 +0700 Subject: [PATCH 2/2] fix lint --- src/components/Search/SearchAutocompleteList.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/components/Search/SearchAutocompleteList.tsx b/src/components/Search/SearchAutocompleteList.tsx index 26176f9ba481..e912eb9a2607 100644 --- a/src/components/Search/SearchAutocompleteList.tsx +++ b/src/components/Search/SearchAutocompleteList.tsx @@ -80,7 +80,7 @@ type SearchAutocompleteListProps = { onHighlightFirstItem?: () => void; /** Ref for textInput */ - textInputRef: React.RefObject; + textInputRef?: React.RefObject; }; const defaultListOptions = { @@ -594,7 +594,7 @@ function SearchAutocompleteList( onLayout={() => { setPerformanceTimersEnd(); setIsInitialRender(false); - if (!!textInputRef.current && ref && 'current' in ref) { + if (!!textInputRef?.current && ref && 'current' in ref) { ref.current?.updateExternalTextInputFocus?.(textInputRef.current.isFocused()); } }}