Closed rougsig closed 2 years ago
It comes from #828 . I'm ready to PR something like this:
getBoxDimensions(event: AbstractDisplacementStateEvent): ClientRect {
let rel: Point;
if (event.event.touches) {
const touch = event.event.touches[0];
rel = this.engine.getRelativePoint(touch.clientX, touch.clientY);
} else {
rel = this.engine.getRelativePoint(event.event.clientX, event.event.clientY)
}
...
}
So I'm suggesting to use second path by default instead of assuming that it is MouseEvent. Do you have better idea for fast fix @renato-bohler ?
It looks like React.MouseEvent
is a TS type. I'm not sure that it can be used with instanceof
. We can use event.event.nativeEvent
and instanceof
native event as second option.
It comes from #828 . I'm ready to PR something like this:
getBoxDimensions(event: AbstractDisplacementStateEvent): ClientRect { let rel: Point; if (event.event.touches) { const touch = event.event.touches[0]; rel = this.engine.getRelativePoint(touch.clientX, touch.clientY); } else { rel = this.engine.getRelativePoint(event.event.clientX, event.event.clientY) } ... }
So I'm suggesting to use second path by default instead of assuming that it is MouseEvent. Do you have better idea for fast fix @renato-bohler ?
It looks like
React.MouseEvent
is a TS type. I'm not sure that it can be used withinstanceof
. We can useevent.event.nativeEvent
andinstanceof
native event as second option.
Hmm, it's weird that this same code works on my project... but well, it seems to me that your change will address that issue.
Steps to reproduce:
Uncaught ReferenceError: TouchEvent is not defined
Chrome:Uncaught TypeError: Cannot read properties of undefined (reading 'x')
Expected result: Selection box is visible and select nodes.