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.

BUG - dispatchEvent should be cancelable

See original GitHub issue

I’m submitting a bug report

Current behavior: All SlickGrid called through EventDispatch should be cancelable, and this requirement is necessary for some of the subscribed event. The event that I currently have problem with is onBeforeEditCell and as answered by the author of SlickGrid in this SO, the way to cancel an edit is to return false which doesn’t do anything when currently used with EventDispatch

Expected/desired behavior:

  • What is the expected behavior? EventDispatch should be cancelable

  • What is the motivation / use case for changing the behavior? Have the same behavior as regular SlickGrid subscribed event.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
ghiscodingcommented, Jul 25, 2018

I actually found the problem with Angular, I forgot to return the dispatchEvent which is needed to return false

// ... this line
-    this.elm.dispatchEvent(new CustomEvent(eventName, eventInit));
+    return this.elm.dispatchEvent(new CustomEvent(eventName, eventInit));

That could help lol

I will push a commit to address this over the weekend, I will also do them as cancelable on all the dispatchEvent, not just the ones with prefix.

0reactions
ghiscodingcommented, Jul 24, 2018

Oh that is interesting, thanks for that, I really didn’t think about changing the arguments as I always do copy & paste lol.

What I like about Aurelia is that they follow the standard and Angular…not so much… and even e.preventDefault() doesn’t prevent the editing. I wouldn’t be surprised that Angular doesn’t handle dispatchEvent event correctly, this might be because in Aurelia we use delegate instead of trigger

I might have to stick with the SlickGrid way until I find the solution (if there is) in Angular

this.onBeforeEditSubscriber = this.angularGrid.slickGrid.onBeforeEditCell.subscribe((e, args) => {
    if (args.item && !this.isCellEditable(args.item, args.column)) {
      return false;
    }
});

just too bad because I need to unsubscribe as well 😦

Read more comments on GitHub >

github_iconTop Results From Across the Web

dispatchEvent(name:canBubble:cancellable:extraInfo ...
A flag indicating whether the event is cancelable. extraInfo. Extra properties that need to be exposed in the event object. completion.
Read more >
EventTarget.dispatchEvent() - Web APIs | MDN
false if event is cancelable, and at least one of the event handlers which received event called Event.preventDefault() . Otherwise true .
Read more >
javascript - dispatchEvent Causes error failed to execute ...
failed to execute 'dispatchEvent' on 'EventTarget': parameter 1 is not of type 'Event'. I have tried everything, and found out that this will...
Read more >
730108 - In theory, dispatchEvent(new Event('submit')) should ...
The form submission algorithm spec [1] describes only a cancelable 'submit' event so Chromium implementation might have simply overlooked the ...
Read more >
Programmatic submit does not work in React 17 #878 - GitHub
Bug What is the current behavior? Submission using form.dispatchEvent(new Event('submit', { cancelable: true })) does not work after ...
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