react-svg-pan-zoom icon indicating copy to clipboard operation
react-svg-pan-zoom copied to clipboard

Clicking ReactSVGPanZoom component does not trigger blur events on other elements

Open otake opened this issue 8 years ago • 3 comments

If you are focused on an input element outside of SVG, and there is a blur event listener on that input. Clicking the SVG does not fire the blur event handler on the input and does not lose focus.

event.preventDefault() on mousedown events seems to interfere with this.

src/features/interactions.js: 48 - in function onMouseDown

Everything seems to work as expected when I remove the preventDefault(). Is there a specific reason to call event.preventDefault() on all the mouse events?

otake avatar Jun 19 '17 16:06 otake

I've just tested it. I tried to remove the preventDefault from onMouseDown, onMouseMove, onMouseUp and onDoubleClick actions. Apparently the default of the browser is to select elements outside the canvas and so the preventDefault is necessary to avoid this.

React SVG Pan Zoom

I've also observed that you are right. The prevent default doesn't release the input focus. https://jsfiddle.net/gc26pd0u/

I have to investigate on it. If you have any suggestions le me know.

chrvadala avatar Jun 20 '17 08:06 chrvadala

Oh I see, that makes sense that you need to stop text from highlighting while dragging the svg. Maybe you only need that preventDefault in onMouseMove?

I worked around my specific problem anyway so its not a huge deal.

otake avatar Jun 20 '17 15:06 otake

@otake - can you please describe more on worked around you added?

shaileshsakaria avatar Sep 09 '21 05:09 shaileshsakaria