fix(ios): reset extendUnderStatusBar on recycle - #76
Open
giaBaoJS wants to merge 1 commit into
Open
Conversation
`updateProps` diffs `extendUnderStatusBar` against the `_extendUnderStatusBar` ivar rather than `oldProps`, because Fabric keeps `_props` across recycling. `prepareForRecycle` resets that ivar but never pushes the reset down to the hosting view, and `resetSheetState` leaves the flag alone. A view recycled from a sheet that set `extendUnderStatusBar` therefore reads `false != NO`, skips the setter, and keeps the flag on, so `resolvedMaxDetentHeight` drops the status-bar overlap subtraction and a full-height detent runs under the status bar for a sheet that never asked for it. Reset the hosting view alongside the ivar so the two stay in sync, the way `restoreInlinePresentation` keeps `_nativeOverlay` in sync.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
On iOS, a recycled
BottomSheetViewcan keep the previous sheet'sextendUnderStatusBar, so a sheet that never set the prop is allowed to rununder the status bar.
updatePropsdiffsextendUnderStatusBaragainst the_extendUnderStatusBarivar rather than
oldProps, because Fabric keeps_propsacross recycling(
RCTViewComponentView.prepareForRecycledoes not reset it):https://github.com/software-mansion-labs/react-native-bottom-sheet/blob/d2bdb71/ios/BottomSheetComponentView.mm#L136-L141
prepareForRecycleresets that ivar, but nothing resets the value it is abaseline for.
resetSheetStateclears springs, detents and layout state andleaves
BottomSheetHostingView.extendUnderStatusBaralone:https://github.com/software-mansion-labs/react-native-bottom-sheet/blob/d2bdb71/ios/BottomSheetHostingView.swift#L444-L470
So when a sheet that set
extendUnderStatusBaris unmounted and its view isdequeued from the recycle pool for a sheet without the prop, the diff reads
false != NO, skips the setter, and the hosting view still holdsYES.resolvedMaxDetentHeightthen returns the raw view height instead ofsubtracting the status-bar overlap:
https://github.com/software-mansion-labs/react-native-bottom-sheet/blob/d2bdb71/ios/BottomSheetHostingView.swift#L1268-L1280
The ivar dates from when it was purely an Objective-C side cache used to
compute the cap locally.
refactor: drop react-native-safe-area-context; measure all geometry natively(6614140) moved the flag onto the hosting viewbut kept resetting only the ivar.
_nativeOverlayavoids this becauseprepareForRecyclecallsrestoreInlinePresentation, which actually undoes the presentation its ivartracks.
Fix
Push the reset through to the hosting view in
prepareForRecycle, so the ivarand the value it is diffed against always agree. Placed after
resetSheetStateso thedidSetrefresh runs against already-cleared state.Repro
Example app, iPhone 17 Pro simulator (iOS 26.3), inline sheets:
card reports
position: 812.0ptand the sheet stops below the status bar.and go back.
812.0pt812.0pt874.0pt812.0pt874 is the full screen height and 812 is that minus the 62pt top safe-area
inset. In step 3 before the change, the sheet header visibly overlaps the clock
and the Dynamic Island.
Test plan
simulator (iOS 26.3).
change, so the prop itself is unaffected.
bun run lint,bun run typecheck,bun run prepare.