retejs / rete

JavaScript framework for visual programming
https://retejs.org
MIT License
10.06k stars 652 forks source link

Prevent node movement on drag in React #320

Closed JStein92 closed 5 years ago

JStein92 commented 5 years ago

I am rendering a <textarea> element inside a node, and would like drag-select the text without moving the node.

I have tried stopPropagation() on the element, but it has no effect.

<textarea
     className={classes.text}
     onChange={onChange}
     onMouseDown={e => e.stopPropagation()}
/>

I have also tried targeting the nativeEvent via nativeEvent.stopPropagation(), to no effect.

<textarea
     className={classes.text}
     onChange={onChange}
     onMouseDown={e => e.nativeEvent.stopPropagation()}
 />

Browser: Chrome Version 75.0.3770.80 (Official Build) (64-bit)

Thank you!

Ni55aN commented 5 years ago

https://github.com/retejs/rete/issues/253#issuecomment-462716901

The same for React, since this event listening by rete core

Try this:

<textarea
     className={classes.text}
     onChange={onChange}
     onPointerMove={e => e.stopPropagation()}
/>
Ni55aN commented 5 years ago

Yep, its working

JStein92 commented 5 years ago

Fantastic, thank you! It's working for me as well. You rock.