question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Cancel Drop after async function

See original GitHub issue

Hi,

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:closed
  • Created 4 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
riktarcommented, May 23, 2019

Hi, @jandresampaio Now if the dropEl callback returns false the drag will be canceled. here: https://github.com/riktar/jkanban/commit/d7ef0efec048595cd0dba34744028b19e55af19c

1reaction
marcosrocha85commented, May 22, 2019

Hello @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.

var oldElement = kanban.findElement(currentStatusId);
kanban.removeElement(currentStatusId);
kanban.addElement(boardId, {
    'id': currentStatusId,
    'title': oldElement.innerHTML
});
Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found