Skip to content

Commit 7759193

Browse files
committed
fix: KeyboardAvoidingView + autoFocus + native-stack
1 parent bb84dcb commit 7759193

1 file changed

Lines changed: 14 additions & 7 deletions

File tree

src/components/KeyboardAvoidingView/index.tsx

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -106,14 +106,21 @@ const KeyboardAvoidingView = forwardRef<
106106
[relativeKeyboardHeight],
107107
);
108108

109-
const onLayoutWorklet = useCallback((layout: LayoutRectangle) => {
110-
"worklet";
109+
const onLayoutWorklet = useCallback(
110+
(layout: LayoutRectangle) => {
111+
"worklet";
111112

112-
if (keyboard.isClosed.value || initialFrame.value === null) {
113-
// eslint-disable-next-line react-compiler/react-compiler
114-
initialFrame.value = layout;
115-
}
116-
}, []);
113+
if (
114+
keyboard.isClosed.value ||
115+
initialFrame.value === null ||
116+
behavior !== "height"
117+
) {
118+
// eslint-disable-next-line react-compiler/react-compiler
119+
initialFrame.value = layout;
120+
}
121+
},
122+
[behavior],
123+
);
117124
const onLayout = useCallback<NonNullable<ViewProps["onLayout"]>>(
118125
(e) => {
119126
runOnUI(onLayoutWorklet)(e.nativeEvent.layout);

0 commit comments

Comments
 (0)