Skip to content

Enhance resize function to track detent index changes#690

Open
allthetime wants to merge 1 commit into
lodev09:mainfrom
allthetime:main
Open

Enhance resize function to track detent index changes#690
allthetime wants to merge 1 commit into
lodev09:mainfrom
allthetime:main

Conversation

@allthetime
Copy link
Copy Markdown

fix(android): prevent TrueSheet collapse to detent 0 on dynamic content layout changes

Summary

Type of Change

  • [✅ ] Bug fix
  • New feature
  • Breaking change
  • Documentation update

Test Plan

repro

Checklist

  • [✅ ] I tested on iOS
  • [ ✅] I tested on Android
  • I tested on Web code only touches one android native file)
  • I updated the documentation (if needed)
  • I added a changelog entry (if needed)

fix(android): prevent TrueSheet collapse to detent 0 on dynamic content layout changes
@vercel
Copy link
Copy Markdown

vercel Bot commented May 20, 2026

@allthetime is attempting to deploy a commit to the RealEdge Inc Team on Vercel.

A member of the Team first needs to authorize it.

@karimcambridge
Copy link
Copy Markdown

I'm wondering if this is the issue I’m having! I have a ride flow and sometimes when lets say a user switches to whatsapp or the map and come back the true sheet is gone, and they get upset. I hope this is the fix!

@allthetime
Copy link
Copy Markdown
Author

allthetime commented May 22, 2026

@karimcambridge you can give this patch a try and see!

I'm running @lodev09/react-native-true-sheet@3.10.1

diff --git a/node_modules/@lodev09/react-native-true-sheet/android/src/main/java/com/lodev09/truesheet/TrueSheetViewController.kt b/node_modules/@lodev09/react-native-true-sheet/android/src/main/java/com/lodev09/truesheet/TrueSheetViewController.kt
index e0c5d2e..cd3ac26 100644
--- a/node_modules/@lodev09/react-native-true-sheet/android/src/main/java/com/lodev09/truesheet/TrueSheetViewController.kt
+++ b/node_modules/@lodev09/react-native-true-sheet/android/src/main/java/com/lodev09/truesheet/TrueSheetViewController.kt
@@ -705,18 +705,25 @@ class TrueSheetViewController(private val reactContext: ThemedReactContext) :
 
   fun resize(detentIndex: Int) {
     if (!isPresented) return
-
     // Commit the new index so keyboardWillHide restores to it instead of the stale one
     if (detentIndexBeforeKeyboard >= 0) {
       detentIndexBeforeKeyboard = detentIndex
     }
-
     setupDimmedBackground()
+    
+    val oldIndex = currentDetentIndex
+    currentDetentIndex = detentIndex
+    
     setStateForDetentIndex(detentIndex)
+    
+    if (oldIndex != detentIndex) {
+      val (index, position, detent) = getDetentInfoWithValue(detentIndex)
+      delegate?.viewControllerDidChangeDetent(index, position, detent)
+      sheetView?.updateGrabberAccessibilityValue(index, detents.size)
+    }
     resizePromise?.invoke()
     resizePromise = null
   }
-
   private fun setupSheetInCoordinator(coordinator: TrueSheetCoordinatorLayout, sheet: TrueSheetBottomSheetView) {
     // Add this controller as content to the sheet
     (parent as? ViewGroup)?.removeView(this)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants