plottable icon indicating copy to clipboard operation
plottable copied to clipboard

Interactions error if registered on detached Component

Open hellochar opened this issue 7 years ago • 3 comments

var xAxis = ...
xAxis.renderTo(...);
new Plottable.Interactions.PanZoom(xScale).attachTo(xAxis);

xAxis.detach().destroy();

Then, try to click or pan/zoom, you'll hit:

Uncaught TypeError: Cannot read property 'node' of undefined at Translator.isInside...

The erroneous line is in transformAwareTranslator:

    return Utils.DOM.contains(component.root().rootElement().node() as Element, e.target as Element);

Workaround: detach the panzoom interaction when you detach the axis.

Request: we should either:

a. detach interactions automatically when the connected element is detached (and re-attach them, maybe?) b. register interactions on the .element() instead of the .rootElement()

hellochar avatar Mar 10 '17 21:03 hellochar

This also reproduces for me when using canvas rendering (which makes sense), but it would be nice if the error here was more helpful for features that are supported w/ SVG but not canvas.

Zerim avatar Nov 03 '17 18:11 Zerim

@Zerim all interactions should support both SVG and Canvas. Which feature are you seeing not working?

hellochar avatar Nov 06 '17 21:11 hellochar

This reproduced for me while trying to attach a Pointer interaction to a Rectangle plot using the canvas renderer.

Zerim avatar Nov 08 '17 04:11 Zerim