microbit-foundation / python-editor-v3

Micro:bit Educational Foundation Python Editor V3
https://python.microbit.org
MIT License
57 stars 36 forks source link

Fix for simulated button clicks for simulator button/pin inputs #1017

Closed microbit-robert closed 2 years ago

microbit-robert commented 2 years ago

Closes #984.

microbit-robert commented 2 years ago

The simulated click seemingly has no delay between mousedown and mouseup which is causing us to end up with unpredictable state in an already complex component. Switching from using state to refs seems to fix the issue, though I'm having trouble reasoning about this change and haven't explored the potential for any unwanted side effects of doing so.

microbit-matt-hillsdon commented 2 years ago

Code-wise this makes sense to me. We only use mouseDown in event handlers and need it to be up-to-date (can't wait for a re-render). I'll play with it some more then approve.

microbit-matt-hillsdon commented 2 years ago

Review link (not sure why missing):

https://review-python-editor-v3.microbit.org/optikey-fix/