@@ -192,7 +192,7 @@ const KeyboardAwareScrollView = forwardRef<
192
192
) ;
193
193
194
194
const scrollFromCurrentPosition = useCallback (
195
- ( customHeight ? : number ) => {
195
+ ( customHeight : number ) => {
196
196
"worklet" ;
197
197
198
198
const prevScrollPosition = scrollPosition . value ;
@@ -207,7 +207,7 @@ const KeyboardAwareScrollView = forwardRef<
207
207
...input . value ,
208
208
layout : {
209
209
...input . value . layout ,
210
- height : customHeight ?? input . value . layout . height ,
210
+ height : customHeight ?? input . value . layout . height , // TODO: math.min? When we have multiline input with limited amount of lines, then custom height can be very big?
211
211
} ,
212
212
} ;
213
213
scrollPosition . value = position . value ;
@@ -217,39 +217,42 @@ const KeyboardAwareScrollView = forwardRef<
217
217
} ,
218
218
[ maybeScroll ] ,
219
219
) ;
220
- const onChangeText = useCallback ( ( ) => {
221
- "worklet" ;
220
+ const onChangeText = useCallback (
221
+ ( customHeight : number ) => {
222
+ "worklet" ;
222
223
223
- // if typing a text caused layout shift, then we need to ignore this handler
224
- // because this event will be handled in `useAnimatedReaction` below
225
- if ( layout . value ?. layout . height !== input . value ?. layout . height ) {
226
- return ;
227
- }
224
+ // if typing a text caused layout shift, then we need to ignore this handler
225
+ // because this event will be handled in `useAnimatedReaction` below
226
+ if ( layout . value ?. layout . height !== input . value ?. layout . height ) {
227
+ return ;
228
+ }
228
229
229
- scrollFromCurrentPosition ( ) ;
230
- } , [ scrollFromCurrentPosition ] ) ;
230
+ scrollFromCurrentPosition ( customHeight ) ;
231
+ } ,
232
+ [ scrollFromCurrentPosition ] ,
233
+ ) ;
234
+ const onChangeTextHandler = useMemo (
235
+ ( ) => debounce ( onChangeText , 200 ) ,
236
+ [ onChangeText ] ,
237
+ ) ;
231
238
const onSelectionChange = useCallback (
232
239
( e : FocusedInputSelectionChangedEvent ) => {
233
240
"worklet" ;
234
241
235
242
if ( e . selection . start . position !== e . selection . end . position ) {
236
243
scrollFromCurrentPosition ( e . selection . end . y ) ;
237
244
}
238
- } ,
239
- [ scrollFromCurrentPosition ] ,
240
- ) ;
241
245
242
- const onChangeTextHandler = useMemo (
243
- ( ) => debounce ( onChangeText , 200 ) ,
244
- [ onChangeText ] ,
246
+ onChangeTextHandler ( e . selection . end . y ) ;
247
+ } ,
248
+ [ scrollFromCurrentPosition , onChangeTextHandler ] ,
245
249
) ;
246
250
247
251
useFocusedInputHandler (
248
252
{
249
- onChangeText : onChangeTextHandler ,
250
253
onSelectionChange : onSelectionChange ,
251
254
} ,
252
- [ onChangeTextHandler , onSelectionChange ] ,
255
+ [ onSelectionChange ] ,
253
256
) ;
254
257
255
258
useSmoothKeyboardHandler (
0 commit comments