react-beautiful-dnd icon indicating copy to clipboard operation
react-beautiful-dnd copied to clipboard

stop reordering

Open Vishal1419 opened this issue 8 years ago • 33 comments

Bug or feature request?

possibly a feature-request

I have 5 stages. I am moving cards from one stage to another by drag and drop. Cards in all the stages are sorted by last updated date. So, when I drag a card from one stage to another, the last updated date of card will be updated. So, my card should always be added to the top of the stage.

In this scenario, it looks foolish to reorder a card as it will be always added to the top. So, I want to stop the reordering of card even when animating it. So, when user drags a card he should see that it will be added to the top of the lane instead of any other order.

Vishal1419 avatar Mar 06 '18 12:03 Vishal1419

When you move into the new list items will naturally move out of the way. This will be the wrong interaction if you can only drop on the top of the list. You could probably use some smoke and mirrors to achieve what you are after but my head is not up to it atm.

The big idea would be that you would need to tell everything except the item dragging that it needs to be ignored by the system...

I'll think about this one later!

However the big thing to note is that your specific pattern is not currently supported

alexreardon avatar Mar 09 '18 02:03 alexreardon

We also have a use case very similar to this. Would be a nice thing to see sometime in the future!

TheMoonDawg avatar Mar 29 '18 14:03 TheMoonDawg

I also need to disable sort.

SPAHI4 avatar Apr 01 '18 21:04 SPAHI4

I have a similar issue with nested draggables. My app consists of manually sortable groups that themselves are droppables with draggables that are sorted automatically. Ideally I would like to disable the interactive reordering when dragging those inner draggables.

neorth avatar Apr 02 '18 11:04 neorth

did anyone find a clever way to achieve this? @Vishal1419

mattkrick avatar Apr 23 '18 18:04 mattkrick

Bumping this. Could be really useful with some patterns.

Otoris avatar Aug 06 '18 23:08 Otoris

I'm looking for a feature like this as well. We're building something similar to JIRA, and we want the rule that if status is changing (i.e. moving to another list), then priority isn't changing (i.e. the global ordering of the cards don't change). In JIRA, you see an overlay appear over the list, and upon dropping it, it appears in the location that matches its global order. This conceptually sounds the same as the OP's request.

andrewbusch7 avatar Aug 10 '18 04:08 andrewbusch7

any solution yet for preventing from reorder while dragging ?????????

a-m-dev avatar Aug 27 '18 13:08 a-m-dev

Any ideas?

matteing avatar Sep 02 '18 18:09 matteing

We have a similar situation here. We need to drag cards among different lists. Depending on different scenarios, some can drop the card into the list and reorder it among other cards in the same list, some can only drop the card into the list but reordering is forbidden due to specific logic.

It would be much better if react-beautiful-dnd provides a more flexible interface to accommodate various situation.

There's a big assumption here that interaction should be the ultimate result, but interaction often plays along with different business logic which we're quite constrained by it.

woohling avatar Oct 18 '18 08:10 woohling

I'm also bumping this. Maybe we can add a prop that visually acts like isDroppable but it allows you to still drop?

I tried a hack with using onDragUpdate to set isDroppable to true whenever the target index > 1 but it caused an infinite loop and crashed the app.

@alexreardon

SandMoshi avatar Oct 19 '18 15:10 SandMoshi

I think the main thing everyone is looking for is the ability to move an item to another list, and not have that list shuffle around as you will be sorting it automatically. When the items shuffle, it gives the illusion that the user has control over the sort order and when they drop the item, the list reorders making it look funky.

My solution which works is to create a white box with position absolute covering the lists when the user starts the drag. The box just says "Drop here to x". This way the items below the cover may shuffle but the user at least doesn't see it. Simple but it works. Hope this helps someone.

realfresh avatar Dec 07 '18 07:12 realfresh

Possible workaround: set in css transform: none!important; on all items except the one the is being dragged

yr-primexm avatar Dec 18 '18 14:12 yr-primexm

Possible workaround: set in css transform: none!important; on all items except the one the is being dragged

I implemented this solution and it works, though it's not ideal. I'd love to just see a prop or something that would let us turn this behavior off.

Our solution:

export const maybeLockTransform = (
  isDragging: boolean,
  style: DraggingStyle | NotDraggingStyle
): DraggingStyle | NotDraggingStyle => {
  const transform = isDragging ? style.transform : "none !important";
  return { ...style, transform };
};

kwhitaker avatar Jan 22 '19 14:01 kwhitaker

On further testing, my above solution breaks down if the user drags an item from List A, but then drops it back on List A. The item being dragged ends up being dropped on top of the nearest element in List A, and I can't seem to find a way to reset the transform after that 😢

kwhitaker avatar Jan 24 '19 16:01 kwhitaker

Made a fix using isDropDisabled for 2 elements in 1 list.

Lukavyi avatar Mar 11 '19 15:03 Lukavyi

I've managed to stop reordering by hiding placeholder:

<div style={{ visibility: 'hidden', height: 0 }}>
  {provided.placeholder}
</div>

madox2 avatar May 07 '19 19:05 madox2

I've managed to stop reordering by hiding placeholder:

<div style={{ visibility: 'hidden', height: 0 }}>
  {provided.placeholder}
</div>

not working for me...

sixfirst avatar May 13 '19 11:05 sixfirst

This will do it, but is pretty hacky and performance could be a lot better if the DOM didn't have to update so much anyway: (props @yr-primexm)

.draggablecontainerhere > div {
  transform: none !important;
}

Would love to see a new prop for this instead. We're also creating a business-oriented workflow and columns are sorted statically.

isaackeyet avatar May 27 '19 20:05 isaackeyet

I'm looking for this too - trying to swap two items between two lists and within a list. The animation that reorders doesn't make sense for that use case.

jianga avatar May 28 '19 05:05 jianga