Skip to content

Commit

Permalink
Do not exit search on scroll
Browse files Browse the repository at this point in the history
  • Loading branch information
paullinator committed Dec 15, 2024
1 parent c41c8fb commit 3b366da
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/components/themed/SearchFooter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ export const SearchFooter = (props: SearchFooterProps) => {
onChangeText={handleSearchChangeText}
value={searchText}
active={isSearching}
onBlur={handleSearchDone}
onCancel={handleSearchDone}
onFocus={handleSearchFocus}
ref={textInputRef}
iconComponent={SearchIconAnimated}
Expand Down
8 changes: 5 additions & 3 deletions src/components/themed/SimpleTextInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ export interface SimpleTextInputProps extends MarginRemProps {
onChangeText?: (text: string) => void
onClear?: () => void
onFocus?: () => void
onCancel?: () => void

// Other React Native TextInput properties:
autoCapitalize?: 'none' | 'sentences' | 'words' | 'characters' // Defaults to 'sentences'
Expand Down Expand Up @@ -172,9 +173,10 @@ export const SimpleTextInput = React.forwardRef<SimpleTextInputRef, SimpleTextIn
const handleClearPress = useHandler(() => {
clear()
})
const handleDonePress = useHandler(() => {
const handleCancelPress = useHandler(() => {
clear()
blur()
if (props.onCancel != null) props.onCancel()
})
const handleFocus = useHandler(() => {
if (active == null) focusAnimation.value = withTiming(1, { duration: baseDuration })
Expand Down Expand Up @@ -210,7 +212,7 @@ export const SimpleTextInput = React.forwardRef<SimpleTextInputRef, SimpleTextIn
<EdgeTouchableWithoutFeedback accessible={false} testID={testID} onPress={() => focus()}>
<InputContainerView disableAnimation={disableAnimation} focusAnimation={focusAnimation} scale={scale}>
<SideContainer size={leftIconSize}>{Icon == null ? null : <Icon color={iconColor} size={leftIconSize} />}</SideContainer>
<TouchableOpacity hitSlop={theme.rem(0.75)} accessible onPress={handleDonePress} testID={`${testID}.doneButton`}>
<TouchableOpacity hitSlop={theme.rem(0.75)} accessible onPress={handleCancelPress} testID={`${testID}.doneButton`}>
<SideContainer size={backIconSize}>
<ChevronBackAnimated color={iconColor} size={backIconSize} />
</SideContainer>
Expand Down Expand Up @@ -255,7 +257,7 @@ export const SimpleTextInput = React.forwardRef<SimpleTextInputRef, SimpleTextIn
</InputContainerView>
</EdgeTouchableWithoutFeedback>
{isIos && (isFocused || active === true) && (
<TouchableOpacity accessible onPress={handleDonePress} testID={`${testID}.cancelButton`}>
<TouchableOpacity accessible onPress={handleCancelPress} testID={`${testID}.cancelButton`}>
<CancelButton>
<CancelText numberOfLines={1} ellipsizeMode="clip">
{lstrings.string_cancel_cap}
Expand Down

0 comments on commit 3b366da

Please sign in to comment.