@delacour/react-native-bottom-sheet 0.7.0-alpha.20261104112157 → 0.7.0-alpha.20261104113139
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.
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@delacour/react-native-bottom-sheet",
|
|
3
|
-
"version": "0.7.0-alpha.
|
|
3
|
+
"version": "0.7.0-alpha.20261104113139",
|
|
4
4
|
"description": "Headless bottom sheet engine for React Native — no tokens, no className",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -329,15 +329,22 @@ function BottomSheetRoot({
|
|
|
329
329
|
// Android's back button closes the top sheet of its host and nothing else:
|
|
330
330
|
// without a registry every sheet is its own top. Subscribed only while
|
|
331
331
|
// presented, so a closed sheet never swallows a press.
|
|
332
|
+
//
|
|
333
|
+
// `methods` is read through a ref, not listed as a dependency. It changes
|
|
334
|
+
// whenever an inline `onOpenChange` does, and `BackHandler` calls the newest
|
|
335
|
+
// listener first: re-subscribing on a parent render would put this sheet's
|
|
336
|
+
// listener ahead of an overlay opened over it.
|
|
337
|
+
const latestMethods = useRef(methods);
|
|
338
|
+
latestMethods.current = methods;
|
|
332
339
|
const registryTop = registry === null ? true : isTop(registry.state, sheetId);
|
|
333
340
|
useEffect(() => {
|
|
334
341
|
if (!presented || !closeOnBack || !registryTop) return;
|
|
335
342
|
const subscription = BackHandler.addEventListener("hardwareBackPress", () => {
|
|
336
|
-
|
|
343
|
+
latestMethods.current.close();
|
|
337
344
|
return true;
|
|
338
345
|
});
|
|
339
346
|
return () => subscription.remove();
|
|
340
|
-
}, [presented, closeOnBack, registryTop
|
|
347
|
+
}, [presented, closeOnBack, registryTop]);
|
|
341
348
|
|
|
342
349
|
const contextValue = useMemo<BottomSheetContextValue>(
|
|
343
350
|
() => ({ ...methods, isOpen, setOpen, index, snapPointCount }),
|
package/src/portal/AGENTS.md
CHANGED
|
@@ -62,6 +62,11 @@ outside the provider — there is nothing to ask without one — and the
|
|
|
62
62
|
under it survives. Without a registry every sheet is its own top. iOS has no
|
|
63
63
|
back button; the unit test on `isTop` is what stands in for the device check.
|
|
64
64
|
|
|
65
|
+
The listener reads the sheet's methods through a ref and does not re-subscribe
|
|
66
|
+
when they change. `BackHandler` calls the newest listener first, and the methods
|
|
67
|
+
change whenever a caller passes an inline `onOpenChange`; re-subscribing on a
|
|
68
|
+
parent render would put the sheet's listener ahead of an overlay opened over it.
|
|
69
|
+
|
|
65
70
|
## Hosts
|
|
66
71
|
|
|
67
72
|
`BottomSheet.Host` is for the one place the root host cannot reach: a native
|