diff --git a/CHANGELOG.md b/CHANGELOG.md index 8a0374c4..9270d9cc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ - **Android**: A sheet whose keyboard starts rising as the present slide ends, such as one that focuses an input around `onWillPresent`, now finishes presenting. It used to never fire `onDidPresent` or resolve `present()`, and kept swallowing taps. ([#1012](https://github.com/lodev09/react-native-true-sheet/pull/1012) by [@JacquesLeupin](https://github.com/JacquesLeupin)) - **Android**: When a sheet presented over another sheet changes its content size right before it dismisses, the sheet behind it now slides back instead of staying pushed down and not draggable. ([#1015](https://github.com/lodev09/react-native-true-sheet/pull/1015) by [@idlework](https://github.com/idlework)) +- **Android**: The keyboard no longer counts against `maxContentHeight`, as on iOS. A sheet now rises above the keyboard instead of stopping at `maxContentHeight` with the keyboard covering the bottom of its content, such as a button below a text input. A sheet already at `maxContentHeight` now rises with the keyboard too, instead of staying put. ([#1017](https://github.com/lodev09/react-native-true-sheet/pull/1017) by [@wildseansy](https://github.com/wildseansy)) ### 💡 Others diff --git a/android/src/main/java/com/lodev09/truesheet/core/TrueSheetDetentCalculator.kt b/android/src/main/java/com/lodev09/truesheet/core/TrueSheetDetentCalculator.kt index b0aec41b..da2b5969 100644 --- a/android/src/main/java/com/lodev09/truesheet/core/TrueSheetDetentCalculator.kt +++ b/android/src/main/java/com/lodev09/truesheet/core/TrueSheetDetentCalculator.kt @@ -132,9 +132,9 @@ class TrueSheetDetentCalculator(private val reactContext: ThemedReactContext) { } else { 0 } - val height = baseHeight + keyboardHeight - footerKeyboardOverlap - val maxAllowedHeight = screenHeight + contentBottomInset - return maxContentHeight?.let { minOf(height, it, maxAllowedHeight) } ?: minOf(height, maxAllowedHeight) + // maxContentHeight caps the content; the keyboard lifts the sheet on top of it, as on iOS. + val cappedHeight = minOf(baseHeight - footerKeyboardOverlap, maxContentHeight ?: Int.MAX_VALUE) + return minOf(cappedHeight + keyboardHeight, screenHeight + contentBottomInset) } fun getBackgroundIndex(sheetTop: Int, displayedIndex: Int): Int {