ui icon indicating copy to clipboard operation
ui copied to clipboard

Drawer Input Obstructed by Keyboard in Mobile

Open WhyAsh5114 opened this issue 5 months ago • 6 comments

Discussed in https://github.com/shadcn-ui/ui/discussions/2564

Originally posted by mrm2234 January 25, 2024 Hi All,

I am trying to use a drawer to capture a user's input using an <Input> component in a Drawer. On mobile, the keyboard is obstructing the user as they are trying to input a number.

Has anyone also seen this behavior / have a fix for it?

TIA!

ex

I'm also facing this issue, the responsive drawer demo on the official website also has this problem when opening in mobile. It does weird height adjustments, often obstructing inputs or adding a lot of empty space at the bottom.

WhyAsh5114 avatar Feb 25 '24 09:02 WhyAsh5114

Hello, i am also having the same issue.

Desgue avatar Feb 26 '24 03:02 Desgue

A minimal repro https://github.com/WhyAsh5114/shadcn-drawer-mobile

https://github.com/shadcn-ui/ui/assets/71895020/42cc6363-e0bb-4e47-a1bd-e4f583614955

WhyAsh5114 avatar Feb 26 '24 05:02 WhyAsh5114

+1

shayant98 avatar Feb 26 '24 05:02 shayant98

+1

SergejSi avatar Feb 28 '24 14:02 SergejSi

Hi! I had the same issue, but after scrolling vaul git find this solution

// This code is simplified for the sake of this article React.useEffect(() => { function onVisualViewportChange() { const visualViewportHeight = window.visualViewport.height; const keyboardHeight = window.innerHeight - visualViewportHeight;

// Difference between window height and height excluding the keyboard
const diffFromInitial = window.innerHeight - visualViewportHeight;

const drawerHeight = drawerRef.current.getBoundingClientRect().height || 0;

drawerRef.current.style.height = `${visualViewportHeight - OFFSET}px`;
drawerRef.current.style.bottom = `${Math.max(diffFromInitial, 0)}px`;

}

window.visualViewport?.addEventListener("resize", onVisualViewportChange);

return () => window.visualViewport?.removeEventListener( "resize", onVisualViewportChange ); }, []);

NeDurov avatar Mar 03 '24 21:03 NeDurov

This issue duplicates #2831. I will try the solution shared by @NeDurov, thanks!

rustyjux avatar Mar 07 '24 00:03 rustyjux

This issue duplicates #2831. I will try the solution shared by @NeDurov, thanks!

Did u fix it?

hazelslab avatar Mar 12 '24 15:03 hazelslab

This issue duplicates #2831. I will try the solution shared by @NeDurov, thanks!

Having the same issue, a white blank "thing" appears wenn i click on an input

hazelslab avatar Mar 12 '24 15:03 hazelslab

Hi this problem is a issue in vaul. I made a comment in a discussion over there. Hope this helps or maybe better to move the questions over there because those are the people directly working on this part. I commented on the issue with a temporary fix so if you need it feel free to check it out

Danillooost avatar Mar 15 '24 21:03 Danillooost