@lodev09/react-native-true-sheet 3.11.14 → 3.11.16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -366,11 +366,22 @@ class TrueSheetView(private val reactContext: ThemedReactContext) :
366
366
  val parentSheet = TrueSheetStackManager.getTopmostSheet()
367
367
  val isFocusedViewWithinSheet = parentSheet?.viewController?.isFocusedViewWithinSheet() == true
368
368
  val shouldDismissKeyboard = isFocusedViewWithinSheet || viewController.isDimmedAtDetentIndex(detentIndex)
369
- if (KeyboardUtils.isKeyboardVisible(reactContext) && shouldDismissKeyboard) {
369
+ if (shouldDismissKeyboard && KeyboardUtils.isKeyboardVisible(reactContext)) {
370
370
  viewController.saveFocusedView()
371
371
  KeyboardUtils.dismiss(this) {
372
- post { present(detentIndex, animated, promiseCallback) }
372
+ post { presentSheet(detentIndex, animated, promiseCallback) }
373
373
  }
374
+ // Blur like iOS so JS focus state stays in sync until restoreFocusedView() refocuses it
375
+ rootView.findFocus()?.clearFocus()
376
+ return
377
+ }
378
+
379
+ presentSheet(detentIndex, animated, promiseCallback)
380
+ }
381
+
382
+ private fun presentSheet(detentIndex: Int, animated: Boolean, promiseCallback: () -> Unit) {
383
+ if (viewController.isPresented) {
384
+ promiseCallback()
374
385
  return
375
386
  }
376
387
 
@@ -1050,7 +1050,7 @@ class TrueSheetViewController(private val reactContext: ThemedReactContext) :
1050
1050
  if (!viewToFocus.isAttachedToWindow) return
1051
1051
  if (viewToFocus.requestFocus()) {
1052
1052
  viewToFocus.postDelayed({
1053
- KeyboardUtils.show(viewToFocus)
1053
+ if (viewToFocus.isFocused) KeyboardUtils.show(viewToFocus)
1054
1054
  }, 100)
1055
1055
  }
1056
1056
  }
@@ -3,6 +3,7 @@ package com.lodev09.truesheet.utils
3
3
  import android.content.Context
4
4
  import android.os.Build
5
5
  import android.view.View
6
+ import android.view.WindowInsets
6
7
  import android.view.inputmethod.InputMethodManager
7
8
  import androidx.core.view.ViewCompat
8
9
  import androidx.core.view.WindowInsetsAnimationCompat
@@ -36,10 +37,22 @@ object KeyboardUtils {
36
37
  * Dismisses the soft keyboard with an optional callback when the animation completes.
37
38
  */
38
39
  fun dismiss(view: View, onComplete: (() -> Unit)?) {
40
+ if (!isKeyboardVisible(view)) {
41
+ onComplete?.invoke()
42
+ return
43
+ }
44
+
39
45
  val imm = view.context.getSystemService(Context.INPUT_METHOD_SERVICE) as? InputMethodManager
40
46
  val focusedView = view.rootView.findFocus()
41
47
 
42
- if (focusedView == null || !isKeyboardVisible(view)) {
48
+ // A keyboard can stay up with nothing focused, e.g. a blur that lands after focus was restored,
49
+ // so hide it through the window instead of treating it as already hidden.
50
+ if (focusedView == null) {
51
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
52
+ view.windowInsetsController?.hide(WindowInsets.Type.ime())
53
+ } else {
54
+ imm?.hideSoftInputFromWindow(view.windowToken, 0)
55
+ }
43
56
  onComplete?.invoke()
44
57
  return
45
58
  }
@@ -1135,7 +1135,8 @@ static char TrueSheetAccessibilityWindowPreviousElementsKey;
1135
1135
 
1136
1136
  #if RNTS_IPHONE_OS_VERSION_AVAILABLE(26_1) && !TARGET_OS_MACCATALYST
1137
1137
  if (@available(iOS 26.1, *)) {
1138
- if (!self.isDesignCompatibilityMode) {
1138
+ // Some 26.1 builds ship `_UIFormSheetPresentationController` without this setter
1139
+ if (!self.isDesignCompatibilityMode && [self.sheet respondsToSelector:@selector(setBackgroundEffect:)]) {
1139
1140
  if (self.backgroundColor || hasBlur) {
1140
1141
  self.sheet.backgroundEffect = [UIColorEffect effectWithColor:[UIColor clearColor]];
1141
1142
  } else {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lodev09/react-native-true-sheet",
3
- "version": "3.11.14",
3
+ "version": "3.11.16",
4
4
  "description": "The true native bottom sheet experience for your React Native Apps.",
5
5
  "source": "./src/index.ts",
6
6
  "main": "./lib/module/index.js",