mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-10 05:12:14 +00:00
fix(ui): attach the bottom sheet's touch listeners when the sheet mounts
The non-passive touchmove listeners on the sheet and its backdrop were bound in an effect that ran while the portaled sheet was still unmounted, and never ran again, so they were never attached. The mounted element is now state, and the listeners follow it.
This commit is contained in:
1 parent
996cc15b50
commit
a0e97a4e54
2 files changed
+17
-5
No files matched your search
@@ -148,6 +148,7 @@ export function BottomSheetContent({
|
||||
const openerRef = React.useRef<HTMLElement | null>(null);
|
||||
const initial: SheetSnap = preview ? "preview" : "full";
|
||||
const [snap, setSnap] = React.useState<SheetSnap>(initial);
|
||||
const [node, setNode] = React.useState<HTMLDivElement | null>(null);
|
||||
|
||||
const drag = useSheetDrag({
|
||||
enabled: draggable,
|
||||
@@ -158,11 +159,13 @@ export function BottomSheetContent({
|
||||
contentRef,
|
||||
overlayRef,
|
||||
probeRef,
|
||||
node,
|
||||
});
|
||||
|
||||
const setContent = React.useCallback(
|
||||
(node: HTMLDivElement | null) => {
|
||||
contentRef.current = node;
|
||||
setNode(node);
|
||||
if (typeof ref === "function") ref(node);
|
||||
else if (ref) ref.current = node;
|
||||
},
|
||||
|
||||
Reference in new issue
Block a user