Skip to content

Commit 97d5f90

Browse files
committed
fix: clamp input height
1 parent 42defa5 commit 97d5f90

File tree

3 files changed

+10
-2
lines changed

3 files changed

+10
-2
lines changed
Loading
Loading

src/components/KeyboardAwareScrollView/index.tsx

+10-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import React, { forwardRef, useCallback, useMemo } from "react";
22
import { findNodeHandle } from "react-native";
33
import Reanimated, {
4+
clamp,
45
interpolate,
56
scrollTo,
67
useAnimatedReaction,
@@ -222,13 +223,17 @@ const KeyboardAwareScrollView = forwardRef<
222223
...input.value,
223224
layout: {
224225
...input.value.layout,
225-
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?
226+
// when we have multiline input with limited amount of lines, then custom height can be very big
227+
// so we clamp it to max input height
228+
height: clamp(customHeight, 0, input.value.layout.height),
226229
},
227230
};
228231
scrollPosition.value = position.value;
229232
maybeScroll(keyboardHeight.value, true);
230233
scrollPosition.value = prevScrollPosition;
231234
layout.value = prevLayout;
235+
236+
console.log({ customHeight });
232237
},
233238
[maybeScroll],
234239
);
@@ -255,9 +260,12 @@ const KeyboardAwareScrollView = forwardRef<
255260
(e: FocusedInputSelectionChangedEvent) => {
256261
"worklet";
257262

263+
console.log(e);
264+
258265
if (e.selection.start.position !== e.selection.end.position) {
259266
console.debug("onSelectionChange - onChangeText");
260-
scrollFromCurrentPosition(e.selection.end.y);
267+
268+
return scrollFromCurrentPosition(e.selection.end.y);
261269
}
262270

263271
onChangeTextHandler(e.selection.end.y);

0 commit comments

Comments
 (0)