Skip to content

Commit

Permalink
[PAY-3522] Hides keyboard when opening purchase drawer from a DM (#10116
Browse files Browse the repository at this point in the history
)
  • Loading branch information
schottra authored Oct 18, 2024
1 parent 52166e8 commit 9fe6c66
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
15 changes: 14 additions & 1 deletion packages/mobile/src/components/drawer/Drawer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import type {
ViewStyle
} from 'react-native'
import {
Keyboard,
Animated,
PanResponder,
Platform,
Expand Down Expand Up @@ -157,6 +158,10 @@ export type DrawerProps = {
* The NowPlayingDrawer exhibits this behavior.
*/
initialOffsetPosition?: number
/**
* Dismiss the keyboard when this drawer opens. Defaults to `false`
*/
dismissKeyboardOnOpen?: boolean
/**
* Whether or not the drawer should close to the initial offset. i.e.
* has it been opened to the offset once?
Expand Down Expand Up @@ -280,7 +285,8 @@ export const Drawer: DrawerComponent = ({
onPanResponderMove,
onPanResponderRelease,
translationAnim: providedTranslationAnim,
disableSafeAreaView
disableSafeAreaView,
dismissKeyboardOnOpen = false
}: DrawerProps) => {
const styles = useStyles()
const insets = useSafeAreaInsets()
Expand Down Expand Up @@ -413,6 +419,13 @@ export const Drawer: DrawerComponent = ({
]
)

// If keyboard was visible when a drawer opens, hide it.
useEffect(() => {
if (isOpen && dismissKeyboardOnOpen && Keyboard.isVisible()) {
Keyboard.dismiss()
}
}, [isOpen, dismissKeyboardOnOpen])

useEffect(() => {
if (isOpen) {
isOpenIntent.current = true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -521,6 +521,7 @@ export const PremiumContentPurchaseDrawer = () => {
onClosed={handleClosed}
isGestureSupported={false}
isFullscreen
dismissKeyboardOnOpen
>
{isLoading ? (
<View style={styles.spinnerContainer}>
Expand Down

0 comments on commit 9fe6c66

Please sign in to comment.