React-beautiful-dnd: Specify Draggable area of Items in a list

Created on 21 Jan 2020  路  7Comments  路  Source: atlassian/react-beautiful-dnd

Description


I have a use case where I want to limit the draggable area for items in a list.
Let's say I have a menu button in each item in the list, I should be able to drag the items from menu button only not the whole item.

Here's a sandbox example
Sandbox

Thanks

idea 馃 untriaged

Most helpful comment

No I didn't find the solution

Thats sad that community doesnt聽help. I spend all day to find solution.
Solution:
Just move {...provided.dragHandleProps} from Draffable div to child, what you want use as a drag area.
Example:

<Draggable draggableId='draggable-1' index={0}>
{(provided)=>(
  <div
  ref={provided.innerRef}
  {...provided.draggableProps}
>
<div {...provided.dragHandleProps}>DRAG AREA HERE</div>
  <li>item</li>
</div>
)
}
</Draggable>

All 7 comments

Description

I have a use case where I want to limit the draggable area for items in a list.
Let's say I have a menu button in each item in the list, I should be able to drag the items from menu button only not the whole item.

Here's a sandbox example
Sandbox

Thanks

did you find solution?

No I didn't find the solution

No I didn't find the solution

Thats sad that community doesnt聽help. I spend all day to find solution.
Solution:
Just move {...provided.dragHandleProps} from Draffable div to child, what you want use as a drag area.
Example:

<Draggable draggableId='draggable-1' index={0}>
{(provided)=>(
  <div
  ref={provided.innerRef}
  {...provided.draggableProps}
>
<div {...provided.dragHandleProps}>DRAG AREA HERE</div>
  <li>item</li>
</div>
)
}
</Draggable>

@mflash123 Thank you for the solution it worked!

@mflash123 It works like a charm. Thanks!

I think it's called placeholder

Closing this thanks to @mflash123

Was this page helpful?
0 / 5 - 0 ratings