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.

Default event action preventing

See original GitHub issue

Using vtk.js in a React project, onClick action does not work.

It appears that the RenderWindowInteractor stops events’ propagation. Besides defining a class that inherits from RenderWindowInteractor and avoids events propagation, do you have an other solution ?

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
florystcommented, Apr 10, 2018

Instead of using onClick, try using onClickCapture in react. That will get the click on the capture phase of event propagation, since vtkjs invokes preventDefault on the bubble phase (which is listened to with onClick).

here’s a modified example of your jsfiddle: https://jsfiddle.net/k1jLk0uw/

I don’t know what removing L55 will do to other parts of vtkjs/projects using vtkjs, and maybe it won’t break anything, but at the very least the above should work for you.

0reactions
florystcommented, Apr 17, 2018

Fixed in #694. Closing.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Event.preventDefault() - Web APIs | MDN
The preventDefault() method of the Event interface tells the user agent that if the event does not get explicitly handled, its default ...
Read more >
Browser default actions - The Modern JavaScript Tutorial
To prevent a default action – use either event.preventDefault() or return false . The second method works only for handlers assigned with on< ......
Read more >
Prevent the default action of an event - HTML DOM
Prevent the default action of an event · 1. Return false for the on<event> · 2. Use the preventDefault() method.
Read more >
How to Prevent Default Action of an Event ... - JavaScript Tutorial
This tutorial shows you how to prevent the default action of an event by using the preventDefault() method of the Event object.
Read more >
What is event.preventDefault() in JavaScript? - Educative.io
In JavaScript, these events' actions can be canceled. Yes, they can be kept from executing the default action that is associated with it....
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