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: Improved Drag target indicator and DragImage #3806

Merged
merged 4 commits into from
Jun 12, 2024
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,24 @@ export const Item = ({
<div
{...context.itemContainerWithoutChildrenProps}
{...context.interactiveElementProps}
onDragStart={(e) => {
context.interactiveElementProps.onDragStart &&
context.interactiveElementProps.onDragStart(e);

// Customize dragging image for form elements
if (isFormElement) {
// Get the box inside the element being dragged
const el = e.currentTarget.children[0];

// Get the position of the cursor inside the box for the offset
const rect = el.getBoundingClientRect();
const x = e.clientX - rect.left;
const y = e.clientY - rect.top;

// Use the inner box for the drag image
e.dataTransfer.setDragImage(el, x, y);
}
}}
className={cn(
"text-left group relative w-full overflow-hidden truncate cursor-pointer h-[60px]",
isSection && isSectionClasses,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,15 +177,12 @@ const ControlledTree: ForwardRefRenderFunction<unknown, TreeDataProviderProps> =
renderItemTitle={({ title }) => <Item.Title title={title} />}
renderItemArrow={({ item, context }) => <Item.Arrow item={item} context={context} />}
renderLiveDescriptorContainer={() => null}
renderDragBetweenLine={({ draggingPosition, lineProps }) => {
renderDragBetweenLine={({ lineProps }) => {
return (
<div
{...lineProps}
className={cn(
"w-full border-b-2 border-blue-focus",
draggingPosition.depth > 0 && "ml-10"
)}
/>
<div {...lineProps}>
<div className="absolute left-0 -ml-2 -mt-2 size-0 border-y-8 border-l-8 border-y-transparent border-l-blue-focus" />
<div className={cn("w-full border-b-1 border-blue-focus")} />
</div>
);
}}
renderItemsContainer={({ children, containerProps }) => {
Expand Down
Loading