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

- BUG - Drawer does not reposition to bottom of the screen when using input in IOS #503

Open
cameronmema opened this issue Nov 4, 2024 · 2 comments

Comments

@cameronmema
Copy link

cameronmema commented Nov 4, 2024

ScreenRecording_11-03-2024.23-01-15_1_1.mp4

I've noticed that when I apply the following class to the Drawer.Content:

`"fixed inset-x-4 bottom-4 z-50 mt-24 flex

h-auto flex-col overflow-hidden rounded-xl border bg-background",`
and place a regular text input inside of it, and then click on it on iOS, the drawer’s bottom position appears to reset to 0 after the keyboard opens, and remains 0 after it closes.

The issue becomes even stranger with a phone input field—on iOS, the larger keyboard pushes the drawer much higher than expected.
Adjusting bottom-4 to bottom-0 does not resolve the issue with the phone input and the drawer being much higher then usual.

It would be optimal for the drawer to reset to the initial bottom-# height you provide after the input is done, even better to maintain the bottom-4 during the keyboard open aswell, for me i like a little spacing from the bottom.

Attached is the screen recording, and my full drawer file.

@cameronmema
Copy link
Author

cameronmema commented Nov 4, 2024

"use client";

import * as React from "react";
import { Drawer as DrawerPrimitive } from "vaul";

import { cn } from "@cm/ui";

const Drawer = ({
shouldScaleBackground = true,
...props
}: React.ComponentProps) => (
<DrawerPrimitive.Root
shouldScaleBackground={shouldScaleBackground}
{...props}
/>
);
Drawer.displayName = "Drawer";

const DrawerTrigger = DrawerPrimitive.Trigger;

const DrawerPortal = DrawerPrimitive.Portal;

const DrawerClose = DrawerPrimitive.Close;

const DrawerOverlay = React.forwardRef<
React.ElementRef,
React.ComponentPropsWithoutRef

(({ className, ...props }, ref) => (
<DrawerPrimitive.Overlay
ref={ref}
className={cn("fixed inset-0 z-50 bg-black/80", className)}
{...props}
/>
));
DrawerOverlay.displayName = DrawerPrimitive.Overlay.displayName;

const DrawerContent = React.forwardRef<
React.ElementRef,
React.ComponentPropsWithoutRef & {
overlayClassName?: string;
hideCloseButton?: boolean;
}

(
(
{ className, children, overlayClassName, hideCloseButton, ...props },
ref,
) => (


<DrawerPrimitive.Content
ref={ref}
className={cn(
"fixed inset-x-4 bottom-4 z-50 mt-24 flex h-auto flex-col overflow-hidden rounded-xl border bg-background",
className,
)}
{...props}
>
{!hideCloseButton && (


)}

    {children}
  </DrawerPrimitive.Content>
</DrawerPortal>

),
);
DrawerContent.displayName = "DrawerContent";

const DrawerHeader = ({
className,
...props
}: React.HTMLAttributes) => (

); DrawerHeader.displayName = "DrawerHeader";

const DrawerFooter = ({
className,
...props
}: React.HTMLAttributes) => (

); DrawerFooter.displayName = "DrawerFooter";

const DrawerTitle = React.forwardRef<
React.ElementRef,
React.ComponentPropsWithoutRef

(({ className, ...props }, ref) => (
<DrawerPrimitive.Title
ref={ref}
className={cn(
"text-lg font-semibold leading-none tracking-tight",
className,
)}
{...props}
/>
));
DrawerTitle.displayName = DrawerPrimitive.Title.displayName;

const DrawerDescription = React.forwardRef<
React.ElementRef,
React.ComponentPropsWithoutRef

(({ className, ...props }, ref) => (
<DrawerPrimitive.Description
ref={ref}
className={cn("text-sm text-muted-foreground", className)}
{...props}
/>
));
DrawerDescription.displayName = DrawerPrimitive.Description.displayName;

export {
Drawer,
DrawerPortal,
DrawerOverlay,
DrawerTrigger,
DrawerClose,
DrawerContent,
DrawerHeader,
DrawerFooter,
DrawerTitle,
DrawerDescription,
};

@darenmalfait
Copy link

Is there a workaround tot this issue for the time being?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants