React-beautiful-dnd: An example for custom drag handle?

Created on 21 Nov 2019  路  2Comments  路  Source: atlassian/react-beautiful-dnd

It's a very common case to solve in many dnd solutions - a custom drag handle. For my feel it's a bit weird, an example for this is missing in the beautifully tailored storybook-thing you guys offer.

Especially weird to the point that egghead.io is offering a course to explain exactly that with react-beautiful-dnd, but i'm not willing to pay a subscription just for that... i can also get behind that magic myself, it just takes some more time ^^

https://egghead.io/lessons/react-designate-control-of-dragging-for-a-react-beautiful-dnd-draggable-with-draghandleprops

idea 馃 untriaged

Most helpful comment

it's spreading the dragHandleProps onto the handle

<Draggable
  key={item.id}
  draggableId={item.id.toString()}
  index={index}
>
{provided => (
  <div
    ref={provided.innerRef}
    {...provided.draggableProps}
    style={{
      minHeight: 40,
      ...provided.draggableProps.style
    }}
  >
    <div {...provided.dragHandleProps}>handle</div>
    item
  </div>
)}
</Draggable>

complete example
https://codesandbox.io/s/vertical-list-dgy2q?fontsize=14&hidenavigation=1&theme=dark

All 2 comments

it's spreading the dragHandleProps onto the handle

<Draggable
  key={item.id}
  draggableId={item.id.toString()}
  index={index}
>
{provided => (
  <div
    ref={provided.innerRef}
    {...provided.draggableProps}
    style={{
      minHeight: 40,
      ...provided.draggableProps.style
    }}
  >
    <div {...provided.dragHandleProps}>handle</div>
    item
  </div>
)}
</Draggable>

complete example
https://codesandbox.io/s/vertical-list-dgy2q?fontsize=14&hidenavigation=1&theme=dark

Especially weird to the point that egghead.io is offering a course to explain exactly that with react-beautiful-dnd, but i'm not willing to pay a subscription just for that... i can also get behind that magic myself, it just takes some more time ^^

The course is free for anyone

Was this page helpful?
0 / 5 - 0 ratings

Related issues

crapthings picture crapthings  路  3Comments

heymartinadams picture heymartinadams  路  3Comments

shalkam picture shalkam  路  3Comments

h182032 picture h182032  路  3Comments

gitleet picture gitleet  路  3Comments