@@ -189,7 +189,7 @@ const KeyboardAwareScrollView = forwardRef<
189
189
) ;
190
190
191
191
const scrollFromCurrentPosition = useCallback (
192
- ( customHeight ? : number ) => {
192
+ ( customHeight : number ) => {
193
193
"worklet" ;
194
194
195
195
const prevScrollPosition = scrollPosition . value ;
@@ -204,7 +204,7 @@ const KeyboardAwareScrollView = forwardRef<
204
204
...input . value ,
205
205
layout : {
206
206
...input . value . layout ,
207
- height : customHeight ?? input . value . layout . height ,
207
+ 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?
208
208
} ,
209
209
} ;
210
210
scrollPosition . value = position . value ;
@@ -214,39 +214,42 @@ const KeyboardAwareScrollView = forwardRef<
214
214
} ,
215
215
[ maybeScroll ] ,
216
216
) ;
217
- const onChangeText = useCallback ( ( ) => {
218
- "worklet" ;
217
+ const onChangeText = useCallback (
218
+ ( customHeight : number ) => {
219
+ "worklet" ;
219
220
220
- // if typing a text caused layout shift, then we need to ignore this handler
221
- // because this event will be handled in `useAnimatedReaction` below
222
- if ( layout . value ?. layout . height !== input . value ?. layout . height ) {
223
- return ;
224
- }
221
+ // if typing a text caused layout shift, then we need to ignore this handler
222
+ // because this event will be handled in `useAnimatedReaction` below
223
+ if ( layout . value ?. layout . height !== input . value ?. layout . height ) {
224
+ return ;
225
+ }
225
226
226
- scrollFromCurrentPosition ( ) ;
227
- } , [ scrollFromCurrentPosition ] ) ;
227
+ scrollFromCurrentPosition ( customHeight ) ;
228
+ } ,
229
+ [ scrollFromCurrentPosition ] ,
230
+ ) ;
231
+ const onChangeTextHandler = useMemo (
232
+ ( ) => debounce ( onChangeText , 200 ) ,
233
+ [ onChangeText ] ,
234
+ ) ;
228
235
const onSelectionChange = useCallback (
229
236
( e : FocusedInputSelectionChangedEvent ) => {
230
237
"worklet" ;
231
238
232
239
if ( e . selection . start . position !== e . selection . end . position ) {
233
240
scrollFromCurrentPosition ( e . selection . end . y ) ;
234
241
}
235
- } ,
236
- [ scrollFromCurrentPosition ] ,
237
- ) ;
238
242
239
- const onChangeTextHandler = useMemo (
240
- ( ) => debounce ( onChangeText , 200 ) ,
241
- [ onChangeText ] ,
243
+ onChangeTextHandler ( e . selection . end . y ) ;
244
+ } ,
245
+ [ scrollFromCurrentPosition , onChangeTextHandler ] ,
242
246
) ;
243
247
244
248
useFocusedInputHandler (
245
249
{
246
- onChangeText : onChangeTextHandler ,
247
250
onSelectionChange : onSelectionChange ,
248
251
} ,
249
- [ onChangeTextHandler , onSelectionChange ] ,
252
+ [ onSelectionChange ] ,
250
253
) ;
251
254
252
255
useSmoothKeyboardHandler (
0 commit comments