ui icon indicating copy to clipboard operation
ui copied to clipboard

Drawer component behaves unexpectdly with Forms, Input Field Loses Focus and Draggable Class Added on Click.

Open itse4elhaam opened this issue 1 year ago • 13 comments

I have a form inside the drawer, text area and selects both work fine but input tags don't get focused when clicked by a mouse, it works when using tab though.

I think the drawer doesn't differentiate correctly between dragging click and input focus click.

To Reproduce, create a drawer component with a form inside it which contains input fields, I used Shadcn Input, Labels, Selects and everything.

Loved the new components but this issue is really bothering me.

shadcn-ui-issue

itse4elhaam avatar Dec 30 '23 12:12 itse4elhaam

Not sure but it might be related to these, haven't found any fixes yet.

  • https://github.com/mui/material-ui/issues/17497
  • https://github.com/facebook/react/pull/15487
  • https://github.com/mui/material-ui/issues/15694

itse4elhaam avatar Dec 30 '23 13:12 itse4elhaam

Also this is happening on chrome/chromium browsers - namely edge/chrome.

itse4elhaam avatar Dec 30 '23 13:12 itse4elhaam

Also have the same issue with inputs.

demczenko avatar Jan 04 '24 09:01 demczenko

I'm having the opposite issue---I can focus on inputs but dragging seems to be broken (Firefox Developer Edition)

ap-1 avatar Jan 05 '24 13:01 ap-1

Also having same issue. Specifically with shadcn Form element. Not an issue when using regular <form> with shadcn <Input> element (as shown in the Responsive Dialog example).

abeisleem avatar Jan 11 '24 10:01 abeisleem

I found an alternative to keep the focus on the input when clicking, in return the drawer can no longer be moved when dragging from the input area.

Add this to your input component :

<input
      onPointerDown={(e) => e.stopPropagation()}
      ...
/>

GuillemotF avatar Jan 13 '24 16:01 GuillemotF

This issue is still ongoing

Adding stopPropagation onpointerdown to the input fix it completely tho

Baptistews avatar Feb 07 '24 08:02 Baptistews

I also have this issue with input, and textarea.

alizada-hadi avatar Feb 17 '24 05:02 alizada-hadi

I found an alternative to keep the focus on the input when clicking, in return the drawer can no longer be moved when dragging from the input area.

Add this to your input component :

<input
      onPointerDown={(e) => e.stopPropagation()}
      ...
/>

@shadcn You should consider adding this solution (or a better one) to this component.

itse4elhaam avatar Feb 19 '24 10:02 itse4elhaam

Just ran into this myself. I tried the onPointerDown solution proposed but it didn't do much. DId anyone figure out a solution?

AdiRishi avatar Feb 25 '24 09:02 AdiRishi

i have exactly the same problem does anyone find a proper solution other than onPointerDown because it didn't work for me

ramyjaber1 avatar Apr 02 '24 09:04 ramyjaber1

Esta opção funcionou, eu estava com um <Input type="date"/> dentro do Drawer e o calendário do input não abria

<input type={'date'} onPointerDown={(e) => e.stopPropagation()} ... />

CarlosSousa2001 avatar Apr 05 '24 20:04 CarlosSousa2001

@itse4elhaam @AdiRishi @ramyjaber1 @shadcn

Here's how to simply fix this problem without sacrificing anything

modify the drawer component in src/components/ui/drawer.tsx and do this

image

bertinselendo avatar Apr 27 '24 20:04 bertinselendo

This issue has been automatically closed because it received no activity for a while. If you think it was closed by accident, please leave a comment. Thank you.

shadcn avatar Jun 11 '24 23:06 shadcn

i still have same issue

mohamed-younes16 avatar Jul 14 '24 15:07 mohamed-younes16

hey @AdiRishi got any way to fix your issue?

sujjeee avatar Jul 20 '24 07:07 sujjeee

@sujjeee no unfortunately I didn't 😞 . I ended up switching to the Sheet component. Very similar visual style and it doesn't suffer the same issues on mobile.

AdiRishi avatar Jul 28 '24 08:07 AdiRishi