GMOD / jbrowse-components

Source code for JBrowse 2, a modern React-based genome browser
https://jbrowse.org/jb2
Apache License 2.0
205 stars 61 forks source link

Fix side scroll in linear synteny view causing the browser "back" action #4426

Closed cmdcolin closed 3 months ago

cmdcolin commented 3 months ago

Using the side scroll in the center area of the linear synteny view is useful, but can trigger the native browser 'back' and 'forward' history actions, which we don't want. This switches the react onWheel handler for a global event handler to properly disable the onWheel behavior because react event handlers can not event.preventDefault() [1]

[1] "React binds all events at the root element (not the document), and the wheel event is binded internally using true option, and I quote MDN:

A Boolean that, if true, indicates that the function specified by listener will never call preventDefault(). If a passive listener does call preventDefault(), the user agent will do nothing other than generate a console warning" https://stackoverflow.com/questions/57358640/cancel-wheel-event-with-e-preventdefault-in-react-event-bubbling