Skip to content

Commit

Permalink
Scope to iOS only
Browse files Browse the repository at this point in the history
  • Loading branch information
gaearon committed Apr 28, 2024
1 parent c175d83 commit f5c8a9e
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/view/screens/Search/Search.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import {NavigationProp} from '#/lib/routes/types'
import {augmentSearchQuery} from '#/lib/strings/helpers'
import {s} from '#/lib/styles'
import {logger} from '#/logger'
import {isNative, isWeb} from '#/platform/detection'
import {isIOS, isNative, isWeb} from '#/platform/detection'
import {listenSoftReset} from '#/state/events'
import {useActorAutocompleteQuery} from '#/state/queries/actor-autocomplete'
import {useActorSearch} from '#/state/queries/actor-search'
Expand Down Expand Up @@ -674,6 +674,7 @@ export function SearchScreen(
value={searchText}
style={[pal.text, styles.headerSearchInput]}
keyboardAppearance={theme.colorScheme}
selectTextOnFocus={isNative}
onFocus={() => {
if (isWeb) {
// Prevent a jump on iPad by ensuring that
Expand All @@ -683,9 +684,12 @@ export function SearchScreen(
})
} else {
setShowAutocomplete(true)
// We'd use selectTextOnFocus, but it's broken:
// https://github.com/facebook/react-native/issues/41988
textInput.current?.setSelection(0, searchText.length)
if (isIOS) {
// We rely on selectTextOnFocus, but it's broken on iOS:
// https://github.com/facebook/react-native/issues/41988
textInput.current?.setSelection(0, searchText.length)
// We still rely on selectTextOnFocus for it to be instant on Android.
}
}
}}
onChangeText={onChangeText}
Expand Down

0 comments on commit f5c8a9e

Please sign in to comment.