Skip to content

Commit 630d0ef

Browse files
committed
feat: add onTextChange prop for handling text changes
1 parent 5533bfc commit 630d0ef

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ const YourComponent = () => {
106106
| debounceDelay | number | No | 200 | Delay before triggering search |
107107
| showLoadingIndicator | boolean | No | true | Show/hide loading indicator |
108108
| style | StyleProp | No | {} | Custom styles object |
109+
| onTextChange | (text: string) => void | No | - | Callback triggered on text input changes |
109110

110111
## Methods
111112

src/GooglePlacesTextInput.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ const GooglePlacesTextInput = forwardRef(
8181
biasPrefixText,
8282
minCharsToFetch = 1,
8383
onPlaceSelect,
84+
onTextChange,
8485
debounceDelay = 200,
8586
showLoadingIndicator = true,
8687
style = {},
@@ -172,7 +173,8 @@ const GooglePlacesTextInput = forwardRef(
172173

173174
const handleTextChange = (text) => {
174175
setInputText(text);
175-
onPlaceSelect(null); // Notify parent when text changes
176+
onPlaceSelect(null);
177+
onTextChange?.(text);
176178

177179
if (debounceTimeout.current) {
178180
clearTimeout(debounceTimeout.current);
@@ -190,7 +192,7 @@ const GooglePlacesTextInput = forwardRef(
190192
onPlaceSelect(place); // Notify parent with selected place
191193
};
192194

193-
// Show suggestions on focus if text length > 1
195+
// Show suggestions on focus if text length > minCharsToFetch
194196
const handleFocus = () => {
195197
if (inputText.length >= minCharsToFetch) {
196198
fetchPredictions(inputText);

0 commit comments

Comments
 (0)