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

Incorrect dragging preview item position when using shadcn popover #847

Open
KamilTheDev opened this issue Oct 5, 2024 · 4 comments
Open

Comments

@KamilTheDev
Copy link

If the draggable list is inside of a shadcn popover, the item is not visible while being dragged. Is there any way to fix this?

@KamilTheDev
Copy link
Author

It looks like the issue is the drag preview item is using a wrong positioning system.

If I drag the item, and put my mouse at the very top left corner of the website, then the drag preview item is shown where it should've been when our mouse was inside the draggable list. I'm not sure how to fix this.

@KamilTheDev
Copy link
Author

Fixed thanks to atlassian/react-beautiful-dnd#2056 :

Ok I've just solved my problem by overriding the left/top definitions of my Draggable to auto:

left: auto !important; top: auto !important;

However, it apparently won't work for vertical list with scrolling:

left: auto !important; top: auto !important;

If your Droppable column is vertical and there exists scroll, this doesnt work when you scroll down. Cant find how to fix it.

I hope a proper fix can be implemented without needing to do this extra fix to get it working.

@KamilTheDev KamilTheDev changed the title Item not visible while dragging when using shadcn popover Incorrect dragging preview item position when using shadcn popover Oct 6, 2024
@demircancelebi
Copy link

demircancelebi commented Oct 27, 2024

For the next person/agent:

{options.map(
  (option: FieldOption, optionIndex: number) => (
    <Draggable
      key={optionIndex}
      draggableId={`option-${optionIndex}`}
      index={optionIndex}
    >
      {(provided) => (
        <div
          ref={provided.innerRef}
          {...provided.draggableProps}
          className="flex gap-2"
          style={{
            ...provided.draggableProps.style,
            left: "auto !important",
            top: "auto !important",
          }}
        >
...

@knightcode
Copy link

I'm guessing this is an issue whenever the Draggable is inside any parent that has position: relative or equivalent, which is my case.

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

3 participants