File tree Expand file tree Collapse file tree 2 files changed +15
-1
lines changed
packages/mobile/src/components
premium-content-purchase-drawer Expand file tree Collapse file tree 2 files changed +15
-1
lines changed Original file line number Diff line number Diff line change @@ -9,6 +9,7 @@ import type {
9
9
ViewStyle
10
10
} from 'react-native'
11
11
import {
12
+ Keyboard ,
12
13
Animated ,
13
14
PanResponder ,
14
15
Platform ,
@@ -157,6 +158,10 @@ export type DrawerProps = {
157
158
* The NowPlayingDrawer exhibits this behavior.
158
159
*/
159
160
initialOffsetPosition ?: number
161
+ /**
162
+ * Dismiss the keyboard when this drawer opens. Defaults to `false`
163
+ */
164
+ dismissKeyboardOnOpen ?: boolean
160
165
/**
161
166
* Whether or not the drawer should close to the initial offset. i.e.
162
167
* has it been opened to the offset once?
@@ -280,7 +285,8 @@ export const Drawer: DrawerComponent = ({
280
285
onPanResponderMove,
281
286
onPanResponderRelease,
282
287
translationAnim : providedTranslationAnim ,
283
- disableSafeAreaView
288
+ disableSafeAreaView,
289
+ dismissKeyboardOnOpen = false
284
290
} : DrawerProps ) => {
285
291
const styles = useStyles ( )
286
292
const insets = useSafeAreaInsets ( )
@@ -413,6 +419,13 @@ export const Drawer: DrawerComponent = ({
413
419
]
414
420
)
415
421
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
+
416
429
useEffect ( ( ) => {
417
430
if ( isOpen ) {
418
431
isOpenIntent . current = true
Original file line number Diff line number Diff line change @@ -521,6 +521,7 @@ export const PremiumContentPurchaseDrawer = () => {
521
521
onClosed = { handleClosed }
522
522
isGestureSupported = { false }
523
523
isFullscreen
524
+ dismissKeyboardOnOpen
524
525
>
525
526
{ isLoading ? (
526
527
< View style = { styles . spinnerContainer } >
You can’t perform that action at this time.
0 commit comments