SortableJS/Sortable

Re-trigger put check based on condition/modifier

Open

#1,838 创建于 2020年5月28日

在 GitHub 查看
 (1 评论) (0 反应) (0 负责人)JavaScript (30,389 star) (3,731 fork)batch import
bughelp wantedquestion

描述

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.

贡献者指南