Cancel Drop after async function
See original GitHub issueHi,
In our business, our items inside a board have different dragTo boards. In this case, what’s the approach to use ? We’ve used the dropEl event to validate if user can drop using an async function but in this case, the kanban.drake.cancel(true) will not work in the callback.
Our code:
const mergedConfig = {
...new KanbanConfiguration(),
...this.configuration,
dropEl: (el, target, source, sibling) => {
const currentStatusId = el.getAttribute("data-boardid");
const targetStatusId = target.parentElement.getAttribute("data-id");
this.workflowService.getWorkflowStateTransition(currentStatusId,targetStatusId).subscribe(
transition => {
/// post to server ...............
},
error => {
// tried this to undo
const copy = el.cloneNode(true);
this.kanban.addElement(currentStatusId, copy);
this.kanban.removeElement(el);
}
);
}
};
this.kanban = new jKanban(mergedConfig);
We tried to undo the drag and drop by removing and adding element to previous board but it does not work.
Thank you.
Issue Analytics
- State:
- Created 4 years ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
Async Cancellation I — 2021-11-10 - Yoshua Wuyts
This means the first cancellation point of any future is immediately after instantiation before the async functions's body has run.
Read more >How can I abort an async-await function after a certain time?
If the server is lagging a lot, I want to abort this activity and return an error. How can I set a timeout...
Read more >Perspectives on Async Cancellation - Eric Holk
When looking from different perspectives, async cancellation can have different meanings, capabilities, and implications.
Read more >Cancel Drag&Drop when awaiting for async operation
Hello ! When I try to cancel the drag&drop directly it works fine but when I have to wait for a service response,...
Read more >Async destructors, async genericity and completion futures
Async drop after future cancellation. Let's start simple, with this trivial function: async fn wait_then_drop_stream(_stream: TlsStream) ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hi, @jandresampaio Now if the dropEl callback returns
false
the drag will be canceled. here: https://github.com/riktar/jkanban/commit/d7ef0efec048595cd0dba34744028b19e55af19cHello @jandresampaio, thank you for using jKanban.
I had something similar in the past and I solved by just getting the old element and adding it again to the board. You have to keep in mind that removing and adding it again will take item to the end of the board.