purescript-react / purescript-react-basic-dom

https://pursuit.purescript.org/packages/purescript-react-basic-dom
Apache License 2.0
11 stars 18 forks source link

Propagate SyntheticEvent to 'this' in preventDefault and stopPropagation functions #48

Closed miuirussia closed 1 year ago

miuirussia commented 1 year ago

Since purescript has ability to compile with different backends (as https://github.com/aristanetworks/purescript-backend-optimizer), functions can be compiled as arrow functions, which results error in react. So we must explicitly specify, that the preventDefault and stopPropagation functions require a SyntheticEvent in 'this'.

See: https://github.com/facebook/react/blob/afe6521e134178920f0523ede4c715942d8f0564/packages/react-dom-bindings/src/events/SyntheticEvent.js#L89

pete-murphy commented 1 year ago

Was able to reproduce the issue here https://github.com/ptrfrncsmrph/purescript-react-events-bug and confirmed the fix locally

mjrussell commented 1 year ago

Thanks for this @miuirussia and @ptrfrncsmrph for additional testing. Just approved to run it through ci and should be able to get this in shortly

mjrussell commented 1 year ago

Release in v6.1.0. Thanks!