A drawer component for React.
Fix: Ensure drawer opens at the specified active snap point on initial render (#473)
Khalafe3ba34d6cf6d
diff --git a/src/context.ts b/src/context.tsindex 4f8742c..6678d64 100644--- a/src/context.ts+++ b/src/context.ts@@ -16,6 +16,7 @@ interface DrawerContextValue {keyboardIsOpen: React.MutableRefObject<boolean>;snapPointsOffset: number[] | null;snapPoints?: (number | string)[] | null;+ activeSnapPointIndex?: number;modal: boolean;shouldFade: boolean;activeSnapPoint?: number | string | null;diff --git a/src/index.tsx b/src/index.tsxindex 99179b6..e128e90 100644--- a/src/index.tsx+++ b/src/index.tsx@@ -769,6 +769,7 @@ export function Root({keyboardIsOpen,modal,snapPointsOffset,+ activeSnapPointIndex,direction,shouldScaleBackground,setBackgroundColorOnScale,@@ -824,6 +825,7 @@ export const Content = React.forwardRef<HTMLDivElement, ContentProps>(function (onDrag,keyboardIsOpen,snapPointsOffset,+ activeSnapPointIndex,modal,isOpen,direction,@@ -891,7 +893,7 @@ export const Content = React.forwardRef<HTMLDivElement, ContentProps>(function (style={snapPointsOffset && snapPointsOffset.length > 0? ({- '--snap-point-height': `${snapPointsOffset[0]!}px`,+ '--snap-point-height': `${snapPointsOffset[activeSnapPointIndex ?? 0]!}px`,...style,} as React.CSSProperties): style