[iOS] `lazy` + `'content'` detent: reopening after expanding to a higher detent crashes with "Detents must be passed in ascending order"
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 48/100
- Tipo di issue
- Bug
- Chiarezza
- Specificata chiaramente
- Stato di attività
- Attiva
- Stack tecnologico
- ios, react-native
- Ambito
- mobile
Direzione di ricerca
Start by tracing ModalBottomSheet detent resolution and lazy content remounting on iOS; the native stack names HostingView.resolveDetentSpecs, resolveDetentsFromLayout, and refreshDetentsFromLayout. Reproduce with detents [0, "content", "90%"], expand, close, and reopen. Done means reopening no longer fatals and the sheet opens at the content detent.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
lazy + 'content' detent: reopening after expanding to a higher detent fatals with "Detents must be passed in ascending order" (iOS)
Version: @swmansion/react-native-bottom-sheet 1.1.0
Platform: iOS simulator (iPhone 18 Pro, iOS ), New Architecture
React Native: 0.88.1 (Expo SDK 58, dev client)
Description
A ModalBottomSheet with lazy and detents [0, 'content', '90%'] works the first time. If you drag it up to the 90% detent, close it, then open it again, the app hits an RCTFatal:
Invalid bottom sheet detent at index 2: resolved position 0.9 is lower than
previous detent position 1.0. Detents must be passed in ascending order.
The content is short (a title, one line of text and a button), so 'content' should resolve far below 0.9. The same steps without lazy work every time.
Steps to reproduce
- Render the sheet below, inside
BottomSheetProvider. - Tap Open. The sheet opens at the
'content'detent. ✅ - Drag it up to the
90%detent. ✅ - Tap Close, or tap the scrim, and let it settle closed. ✅
- Tap Open again. 💥 Fatal error.
import { useState } from "react";
import { Button, StyleSheet, Text, View } from "react-native";
import { ModalBottomSheet } from "@swmansion/react-native-bottom-sheet";
export function Repro() {
const [index, setIndex] = useState(0);
return (
<View style={{ flex: 1, justifyContent: "center" }}>
<Button title="Open" onPress={() => setIndex(1)} />
<ModalBottomSheet
lazy
index={index}
detents={[0, "content", "90%"]}
onIndexChange={setIndex}
onCloseRequest={() => setIndex(0)}
scrimColor="rgba(0, 0, 0, 0.4)"
surface={<View style={[StyleSheet.absoluteFill, { backgroundColor: "white" }]} />}
surfaceStyle={{ borderTopLeftRadius: 32, borderTopRightRadius: 32 }}
>
<View style={{ padding: 20, paddingBottom: 40, gap: 16 }}>
<Text style={{ fontSize: 22, fontWeight: "600" }}>Native bottom sheet</Text>
<Text>Drag up to 90%, then close and reopen.</Text>
<Button title="Close" onPress={() => setIndex(0)} />
</View>
</ModalBottomSheet>
</View>
);
}
Expected
On reopening, the sheet opens at the 'content' detent, as it did the first time.
Actual
'content' resolves to 1.0 (full available height) when the sheet remounts, so it fails the ascending-order check against '90%' and the app crashes.
Native stack (top frames):
RCTFatal
-[BottomSheetComponentView bottomSheetView:didReportError:]
-[BottomSheetContentView bottomSheetHostingView:didReportError:]
HostingView.resolveDetentSpecs
HostingView.resolveDetentsFromLayout
HostingView.refreshDetentsFromLayout
HostingView.setDetents
-[BottomSheetContentView setDetents:]
-[BottomSheetComponentView updateProps:oldProps:]
RCTPerformMountInstructions
-[RCTMountingManager performTransaction:]
Notes
- My guess, from the error: when
lazyremounts the content,'content'is resolved before the remounted content has its real height, possibly using the height from the last time the sheet was open at90%. - Even when
'content'really is taller than a later fixed detent, a fatal error seems harsh. Clamping it, or showing a dev-only warning, would be easier to work with, since content height isn't always predictable. - Workaround: remove
lazy.
- Lingua principale
- Kotlin
- Stelle
- 536
- Fork
- 24
- Merge medio
- 12h 10m
- PR unite (30g)
- 22
Preparare l'ambiente
Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di software-mansion/react-native-bottom-sheet
-
Android: NoSuchElementException in ScrollIndicators.refit when a scroll view is garbage collectedAperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100
software-mansion/react-native-bottom-sheet#140 · 1 commento · 1 reazione ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 35/100
software-mansion/react-native-bottom-sheet#137 ·
I maintainer di solito rispondono entro 1 giorno
-
Feature request: opt-in native keyboard avoidanceForse già presa @Asad-Butt l’ha presa 5 giorni fa. Aperta
Difficoltà 4/5 3-5 giorni Idoneità per principianti 22/100
software-mansion/react-native-bottom-sheet#134 · 1 commento · 2 reazioni ·
I maintainer di solito rispondono entro 1 giorno
-
enhancement
Difficoltà 4/5 3-5 giorni Idoneità per principianti 52/100
software-mansion/react-native-bottom-sheet#74 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
enhancement
Difficoltà 5/5 Più di una settimana Idoneità per principianti 35/100
software-mansion/react-native-bottom-sheet#64 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di software-mansion/react-native-bottom-sheet
Issue simili
-
Remove Collect againAperta
Difficoltà 1/5 1-3 ore Idoneità per principianti 86/100
thisisartman/Meguri#211 ·
I maintainer di solito rispondono entro 1 giorno
-
follow-up
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 75/100
I maintainer di solito rispondono entro 1 giorno
-
area:android fleet
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
I maintainer di solito rispondono entro 1 giorno
-
bug needs-triage
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
emm3000/myGame#2175 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno