Skip to content

Best practices to disallow / deny / disable drop actions on some droppables and how to visualize this #662

Answered by jarredwitt
olee asked this question in Q&A
Discussion options

You must be logged in to vote

Hi @olee, I just finished a page builder that had this ability with nested containers. This can be done after you include some helpful data in the draggables and droppables.

I'll use rows, columns and elements as an example. A column can only be dropped over a row and an element can only be dropped over a column.

We set up our draggables/droppables to have some helpful hints in the data prop, something like:

const {...} = useDroppable({
  id,
  data: {
   type: 'row', // could also be column since those are droppable too
  }
});

const {...} = useDraggable({
  id,
  data: {
    type: 'column', // could also be element
  }
});

Once you have that setup you use the onDragOver event handler f…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@olee
Comment options

Answer selected by olee
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants