Skip to content

Commit e431917

Browse files
authored
fix: KeyboardAvoidingView incorrect layout (#954)
## 📜 Description Don't allow `height` to be `0` when `KeyboardAvoidingView` has `behavior="height"`. ## 💡 Motivation and Context The problem is that when we apply `{height: 0}` and then apply `{}`, then view doesn't reset its styles. To overcome that problem I decided to avoid cases when we apply non-positive height (i. e. `<= 0`). Closes #949 ## 📢 Changelog <!-- High level overview of important changes --> <!-- For example: fixed status bar manipulation; added new types declarations; --> <!-- If your changes don't affect one of platform/language below - then remove this platform/language --> ### JS - add `height > 0` condition; ## 🤔 How Has This Been Tested? Tested in example app. ## 📸 Screenshots (if appropriate): |Before|After| |-------|-----| |<video src="https://github.com/user-attachments/assets/1af0e90f-8ed3-40d5-a654-62fb860d697b">|<video src="https://github.com/user-attachments/assets/e2ffce05-0377-4693-99f2-ddba036d55cf">| ## 📝 Checklist - [x] CI successfully passed - [x] I added new mocks and corresponding unit-tests if library API was changed
1 parent 427374f commit e431917

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/components/KeyboardAvoidingView/index.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,12 +145,13 @@ const KeyboardAvoidingView = forwardRef<
145145
const translateY = interpolateToRelativeKeyboardHeight(translate.value);
146146
const paddingBottom = interpolateToRelativeKeyboardHeight(padding.value);
147147
const bottomHeight = enabled ? bottom : 0;
148+
const height = frame.value.height - bottomHeight;
148149

149150
switch (behavior) {
150151
case "height":
151-
if (!keyboard.isClosed.value) {
152+
if (!keyboard.isClosed.value && height > 0) {
152153
return {
153-
height: frame.value.height - bottomHeight,
154+
height,
154155
flex: 0,
155156
};
156157
}

0 commit comments

Comments
 (0)