SortableJS/Sortable

Re-trigger put check based on condition/modifier

Open

#1 838 ouverte le 28 mai 2020

Voir sur GitHub
 (1 commentaire) (0 réactions) (0 assignés)JavaScript (3 731 forks)batch import
bughelp wantedquestion

Métriques du dépôt

Stars
 (30 389 stars)
Métriques de merge PR
 (Aucune PR mergée en 30 j)

Description

Right now, I'm using the put option inside groups to refuse some items based on dynamic rules, which can be ignored if the user holds the Ctrl key.

The problem is, when the user stops holding the Ctrl key, without initiating the drop, the put rules don't apply any more and the item can then be dropped, even though it would've been blocked based on the put rules. I know that "put" behaves correctly in that case, since holding the Ctrl key returned true for that specific list and rerunning the put rules wouldn't make sense any more.

Is there a way, where I can re-trigger the put rules? I already tried to toggle the disabled state for the active sortable instance but this doesn't seem to work. I also tried to move the ghost element back to the previous parent but this didn't work either.

Demo: https://jsbin.com/vokuwuboca/edit?js,output

Steps:

  1. Chose item from first list
  2. Hold Ctrl key
  3. Start dragging to second list => Not possible, which is expected
  4. Release Ctrl key => Possible, also expected
  5. Now hold Ctrl key again => Shouldn't be possible anymore based put rules => Expectation: Ghost element is reverted to previous parent -> drop not possible.

Guide contributeur