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.

Controls break events due to stopPropagation

See original GitHub issue

for reference: https://github.com/pmndrs/drei/issues/171

	function onMouseDown( event ) {

		event.preventDefault();
		event.stopPropagation();

https://github.com/mrdoob/three.js/blob/dev/examples/jsm/controls/TrackballControls.js

three jsm controls take away the users ability to raycast properly or use events in general, because events are stopped by the control. depending on what the user does, our own event either work, work sometimes, or don’t work at all. it is a race condition, which is more dangerous for app stability.

imo preventdefault and especially stoppropagation in a control is a bad idea. i read a little back and found what made you merge it, it appeared to fix some problem but even the authors back then admitted it was an accidental hack (due to the race condition) and would like to remove it. they saw an issue fixed, but now caused a problem for everything else that uses events.

but as it stands, if any control is used, they take over and prevent the user from interacting with the scene.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:14 (10 by maintainers)

github_iconTop GitHub Comments

3reactions
drcmdacommented, May 22, 2021

it is still broken it seems. i think the problem really is preventdefault. you can see it here: https://codesandbox.io/s/focused-paper-fme44?file=/src/App.js ref: https://github.com/pmndrs/three-stdlib/issues/61

once orbitcontrols are present outer events are broken. if i comment out preventdefault it works. i still think it should not be [orbit]controls responsibility to handle browser defaults but the users.

1reaction
mrdoobcommented, Feb 24, 2021

@mrdoob If you like, I can make a PR so we can test this on dev for r127.

Merged. Lets see how it goes 👍

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to Stop Propagation of an Event in JS - JavaScript Tutorial
This tutorial shows you how to stop the propagation of an event in both capturing and bubbling phases using the Event.stopPropagation() method.
Read more >
Event.stopPropagation() - Web APIs | MDN
The stopPropagation() method of the Event interface prevents further propagation of the current event in the capturing and bubbling phases.
Read more >
How to stop event propagation with inline onclick attribute?
Use event. stopPropagation(). There's no such thing as the event object in FireFox. The event object is a parameter of the callback.
Read more >
event.stopPropagation() in a modular system - Moxio
If you event.stopPropagation() in the click listener of the checkbox in the bubbling phase the event will no longer bubble up and it...
Read more >
Using stopPropagation() to Stop Event Bubbling in JavaScript
Events in JavaScript are one of the core features of the language that have given us the modern, reactive internet that we know...
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