File tree Expand file tree Collapse file tree 3 files changed +29
-17
lines changed Expand file tree Collapse file tree 3 files changed +29
-17
lines changed Original file line number Diff line number Diff line change @@ -4,15 +4,15 @@ A customizable React Native TextInput component for Google Places Autocomplete u
4
4
5
5
## Features
6
6
7
- - 🎨 Fully customizable UI
8
- - ⌨️ Debounced search
9
- - 🗑️ Clear button (x)
10
- - 🔄 Loading indicator
11
- - 📱 Keyboard-aware
12
- - 🔍 Custom place types filtering
13
- - 🌍 RTL support
14
- - 🌐 Multi-language support
15
- - 🎯 TypeScript support
7
+ - Fully customizable UI
8
+ - Debounced search
9
+ - Clear button (x)
10
+ - Loading indicator
11
+ - Keyboard-aware
12
+ - Custom place types filtering
13
+ - RTL support
14
+ - Multi-language support
15
+ - TypeScript support
16
16
17
17
## Preview
18
18
@@ -172,6 +172,7 @@ const StyledExample = () => {
172
172
| showLoadingIndicator | boolean | No | true | Show/hide loading indicator |
173
173
| showClearButton | boolean | No | true | Show/hide the input clear button |
174
174
| forceRTL | boolean | No | undefined | Force RTL layout direction |
175
+ hideOnKeyboardDismiss | boolean | No | false | Hide suggestions when keyboard is dismissed
175
176
| ** Event Handlers** |
176
177
| onPlaceSelect | (place: Place \| null) => void | Yes | - | Callback when place is selected |
177
178
| onTextChange | (text: string) => void | No | - | Callback triggered on text input changes |
Original file line number Diff line number Diff line change @@ -40,6 +40,7 @@ const GooglePlacesTextInput = forwardRef(
40
40
showClearButton = true ,
41
41
forceRTL = undefined ,
42
42
style = { } ,
43
+ hideOnKeyboardDismiss = false ,
43
44
} ,
44
45
ref
45
46
) => {
@@ -60,15 +61,19 @@ const GooglePlacesTextInput = forwardRef(
60
61
61
62
// Add keyboard listener
62
63
useEffect ( ( ) => {
63
- const keyboardDidHideSubscription = Keyboard . addListener (
64
- 'keyboardDidHide' ,
65
- ( ) => setShowSuggestions ( false )
66
- ) ;
64
+ if ( hideOnKeyboardDismiss ) {
65
+ const keyboardDidHideSubscription = Keyboard . addListener (
66
+ 'keyboardDidHide' ,
67
+ ( ) => setShowSuggestions ( false )
68
+ ) ;
67
69
68
- return ( ) => {
69
- keyboardDidHideSubscription . remove ( ) ;
70
- } ;
71
- } , [ ] ) ;
70
+ return ( ) => {
71
+ keyboardDidHideSubscription . remove ( ) ;
72
+ } ;
73
+ }
74
+ // Return empty cleanup function if not using the listener
75
+ return ( ) => { } ;
76
+ } , [ hideOnKeyboardDismiss ] ) ;
72
77
73
78
// Expose methods to parent through ref
74
79
useImperativeHandle ( ref , ( ) => ( {
Original file line number Diff line number Diff line change @@ -89,6 +89,12 @@ export interface GooglePlacesTextInputProps extends TextInputProps {
89
89
* Whether to disable suggestions dropdown
90
90
*/
91
91
disableSuggestions ?: boolean ;
92
+
93
+ /**
94
+ * Whether to hide suggestions when keyboard is dismissed
95
+ * @default false
96
+ */
97
+ hideOnKeyboardDismiss ?: boolean ;
92
98
}
93
99
94
100
export interface GooglePrediction {
You can’t perform that action at this time.
0 commit comments