Skip to content

Commit 9fe6c66

Browse files
authored
[PAY-3522] Hides keyboard when opening purchase drawer from a DM (#10116)
1 parent 52166e8 commit 9fe6c66

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

packages/mobile/src/components/drawer/Drawer.tsx

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import type {
99
ViewStyle
1010
} from 'react-native'
1111
import {
12+
Keyboard,
1213
Animated,
1314
PanResponder,
1415
Platform,
@@ -157,6 +158,10 @@ export type DrawerProps = {
157158
* The NowPlayingDrawer exhibits this behavior.
158159
*/
159160
initialOffsetPosition?: number
161+
/**
162+
* Dismiss the keyboard when this drawer opens. Defaults to `false`
163+
*/
164+
dismissKeyboardOnOpen?: boolean
160165
/**
161166
* Whether or not the drawer should close to the initial offset. i.e.
162167
* has it been opened to the offset once?
@@ -280,7 +285,8 @@ export const Drawer: DrawerComponent = ({
280285
onPanResponderMove,
281286
onPanResponderRelease,
282287
translationAnim: providedTranslationAnim,
283-
disableSafeAreaView
288+
disableSafeAreaView,
289+
dismissKeyboardOnOpen = false
284290
}: DrawerProps) => {
285291
const styles = useStyles()
286292
const insets = useSafeAreaInsets()
@@ -413,6 +419,13 @@ export const Drawer: DrawerComponent = ({
413419
]
414420
)
415421

422+
// If keyboard was visible when a drawer opens, hide it.
423+
useEffect(() => {
424+
if (isOpen && dismissKeyboardOnOpen && Keyboard.isVisible()) {
425+
Keyboard.dismiss()
426+
}
427+
}, [isOpen, dismissKeyboardOnOpen])
428+
416429
useEffect(() => {
417430
if (isOpen) {
418431
isOpenIntent.current = true

packages/mobile/src/components/premium-content-purchase-drawer/PremiumContentPurchaseDrawer.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -521,6 +521,7 @@ export const PremiumContentPurchaseDrawer = () => {
521521
onClosed={handleClosed}
522522
isGestureSupported={false}
523523
isFullscreen
524+
dismissKeyboardOnOpen
524525
>
525526
{isLoading ? (
526527
<View style={styles.spinnerContainer}>

0 commit comments

Comments
 (0)