arnog / mathlive

A web component for easy math input
https://cortexjs.io/mathlive
MIT License
1.26k stars 260 forks source link

[Bug] Switching from Latex mode to Math mode using the mouse does not trigger onInput #2415

Closed Mathias-S closed 1 week ago

Mathias-S commented 1 week ago

Description

Entering something in Latex mode, then clicking somewhere else the Mathfield (outside the Latex formula you're writing), exits Latex mode and inserts the Latex as math, just like when pressing "Enter" or "Esc". However, using the mouse doesn't fire the onInput event.

Steps to Reproduce

(Required) Provide steps that are specific and repeatable

  1. Enter something in math mode (e.g. 123)
  2. Type \ then a Latex command, e.g. \cdot
  3. Instead of "Enter"/"Esc" to exit latex mode, use the mouse to click somewhere else in the text field (e.g. on the 123)

Actual Behavior

Using the mouse to exit Latex mode in step 3 doesn't cause an onInput event to fire, so there's no way to know that the content of the Mathfield has changed.

In the following recording, the first is inserted by clicking with the mouse, the second is inserted by pressing Enter.

https://github.com/arnog/mathlive/assets/225531/5bc163e1-02eb-47d9-939d-90b94892bb3e

Expected Behavior

onInput should fire when exiting Latex mode with a mouseclick (similarly to pressing "Enter"/"Esc" to exit Latex mode).

Environment

MathLive 0.100.0 on Chrome, macOS.

arnog commented 1 week ago

Great bug report, clear description and steps to reproduce. Thank you!