stop auto hiding keyboard, allow scrollview props to handle

This commit is contained in:
Samuel Newman
2024-09-30 15:15:13 +03:00
parent 91d6753d4f
commit b9452ba15a
2 changed files with 17 additions and 7 deletions
+15 -7
View File
@@ -1,9 +1,8 @@
import React, {useImperativeHandle} from 'react' import React, {useImperativeHandle} from 'react'
import { import {
Dimensions,
Keyboard,
Pressable, Pressable,
StyleProp, StyleProp,
useWindowDimensions,
View, View,
ViewStyle, ViewStyle,
} from 'react-native' } from 'react-native'
@@ -96,6 +95,7 @@ export function Outer({
const insets = useSafeAreaInsets() const insets = useSafeAreaInsets()
const closeCallbacks = React.useRef<(() => void)[]>([]) const closeCallbacks = React.useRef<(() => void)[]>([])
const {setDialogIsOpen} = useDialogStateControlContext() const {setDialogIsOpen} = useDialogStateControlContext()
const {height: windowHeight} = useWindowDimensions()
/* /*
* Used to manage open/closed, but index is otherwise handled internally by `BottomSheet` * Used to manage open/closed, but index is otherwise handled internally by `BottomSheet`
@@ -179,8 +179,7 @@ export function Outer({
// Android // Android
importantForAccessibility="yes" importantForAccessibility="yes"
style={[a.absolute, a.inset_0]} style={[a.absolute, a.inset_0]}
testID={testID} testID={testID}>
onTouchMove={() => Keyboard.dismiss()}>
<BottomSheet <BottomSheet
enableDynamicSizing={!hasSnapPoints} enableDynamicSizing={!hasSnapPoints}
enablePanDownToClose enablePanDownToClose
@@ -206,7 +205,7 @@ export function Outer({
{ {
borderTopLeftRadius: 40, borderTopLeftRadius: 40,
borderTopRightRadius: 40, borderTopRightRadius: 40,
height: Dimensions.get('window').height * 2, height: windowHeight * 2,
}, },
]} ]}
/> />
@@ -243,11 +242,20 @@ export function Inner({children, style}: DialogInnerProps) {
export const ScrollableInner = React.forwardRef< export const ScrollableInner = React.forwardRef<
BottomSheetScrollViewMethods, BottomSheetScrollViewMethods,
DialogInnerProps DialogInnerProps
>(function ScrollableInner({children, style}, ref) { >(function ScrollableInner(
{
children,
style,
keyboardShouldPersistTaps = 'handled',
keyboardDismissMode = 'on-drag',
},
ref,
) {
const insets = useSafeAreaInsets() const insets = useSafeAreaInsets()
return ( return (
<BottomSheetScrollView <BottomSheetScrollView
keyboardShouldPersistTaps="handled" keyboardShouldPersistTaps={keyboardShouldPersistTaps}
keyboardDismissMode={keyboardDismissMode}
style={[ style={[
a.flex_1, // main diff is this a.flex_1, // main diff is this
a.p_xl, a.p_xl,
+2
View File
@@ -66,10 +66,12 @@ export type DialogInnerProps =
accessibilityLabelledBy: A11yProps['aria-labelledby'] accessibilityLabelledBy: A11yProps['aria-labelledby']
accessibilityDescribedBy: string accessibilityDescribedBy: string
keyboardDismissMode?: ScrollViewProps['keyboardDismissMode'] keyboardDismissMode?: ScrollViewProps['keyboardDismissMode']
keyboardShouldPersistTaps?: ScrollViewProps['keyboardShouldPersistTaps']
}> }>
| DialogInnerPropsBase<{ | DialogInnerPropsBase<{
label: string label: string
accessibilityLabelledBy?: undefined accessibilityLabelledBy?: undefined
accessibilityDescribedBy?: undefined accessibilityDescribedBy?: undefined
keyboardDismissMode?: ScrollViewProps['keyboardDismissMode'] keyboardDismissMode?: ScrollViewProps['keyboardDismissMode']
keyboardShouldPersistTaps?: ScrollViewProps['keyboardShouldPersistTaps']
}> }>