Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: Ensure drawer opens at the specified active snap point on initial render #473

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 3 additions & 1 deletion src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -765,6 +765,7 @@ export function Root({
keyboardIsOpen,
modal,
snapPointsOffset,
activeSnapPointIndex,
direction,
shouldScaleBackground,
setBackgroundColorOnScale,
Expand Down Expand Up @@ -818,6 +819,7 @@ export const Content = React.forwardRef<HTMLDivElement, ContentProps>(function (
onDrag,
keyboardIsOpen,
snapPointsOffset,
activeSnapPointIndex,
modal,
isOpen,
direction,
Expand Down Expand Up @@ -885,7 +887,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
Expand Down
Loading