Skip to content

fix(android): reconfigure detents changed while present() runs - #1022

Open
Kijomimi wants to merge 2 commits into
lodev09:mainfrom
Kijomimi:fix/android-detents-change-during-present
Open

Kijomimi wants to merge 2 commits into
lodev09:mainfrom
Kijomimi:fix/android-detents-change-during-present

Conversation

@Kijomimi

Copy link
Copy Markdown

Summary

On Android a detents change that lands while present() runs is lost: the behavior keeps the stops it was configured with, while the container follows the new detents.

How it happens: present() calls setupSheetDetents() before isPresented = true. Its updateStateDimensions() resizes the container through the Fabric state, and Fabric mounts the pending props right there. If those props carry new detents, setDetents stores them, but finalizeUpdates() skips updateSheetIfNeeded() because isPresented is still false. After that nothing reconfigures the behavior.

The result: the sheet settles at the old half-expanded/expanded offsets, while updateStateDimensions() sizes the container to the new detents. When the new stops are lower, the content ends partway down the sheet and the rest of the sheet is empty. During a drag the container follows the finger, so the content shows up and disappears again when the sheet settles.

We hit this with detents computed from measured content: the first detents are estimates and the real ones arrive while the sheet is presenting. Logs from the device:

present idx=0 detents=[0.083, 0.6, 0.9]
setupSheetDetents apply=true presented=false detents=[0.083, 0.6, 0.9]
setDetents [0.083, 0.518, 0.694] presented=false      <- mounted inside present(), reconfigure skipped
state=4 ... detents=[0.083, 0.518, 0.694] cfg=[0.083, 0.6, 0.9]

The fix: at the end of present(), once isPresented is true, reconfigure with applyState = false if the detents differ from the configured ones. The posted present settle then uses the new stops. This looks like the Android side of #555.

Type of Change

  • Bug fix
  • New feature
  • Breaking change
  • Documentation update

Test Plan

Tested on 4.1.0 through patch-package, RN 0.88, Xiaomi POCO F5 (Android 15):

  • A sheet with three fraction detents whose middle and top stops are recomputed after the content is measured. Without the fix the sheet often settles at the first-render stops with empty space below the content. With the fix, logs show the reconfigure after present() and the sheet settles at the new stops.
  • Detent changes during the present animation, during a drag and at rest behave as before: they go through setupSheetDetentsForSizeChange().

Checklist

  • I tested on iOS
  • I tested on Android
  • I tested on Web
  • I updated the documentation (if needed)
  • I added a changelog entry (if needed)

@vercel

vercel Bot commented Nov 11, 2026

Copy link
Copy Markdown

Someone is attempting to deploy a commit to the lodev09 Team on Vercel.

A member of the Team first needs to authorize it.

This branch has not been deployed

No deployments
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.

1 participant