ShaMan123 / react-math-view

React bindings for MathLive
https://shaman123.github.io/react-math-view/
9 stars 12 forks source link

Caret thrown to end, when typing inside fractal in controlled input #5

Closed hanshs closed 2 years ago

hanshs commented 2 years ago

Describe the bug When typing on either side of a fractal value, it allows typing one character and then caret is thrown to the end of the value. Happens only with controlled inputs

To Reproduce Steps to reproduce the behavior:

  1. Go to https://shaman123.github.io/react-math-view/
  2. Focus on any of the controlled input examples
  3. Type shift+/ to convert to fractal
  4. Type any value

Expected behavior Caret stays within the focused fractal side

Desktop (please complete the following information):

ShaMan123 commented 2 years ago

I thought this was resolved. I opened a related issue that was resolved. Caret was thrown when using setOptions. As you can see from the source code it seems it does that now when using setValue. Perhaps try opening a new issue in mathlive after testing if downgrading mathlive to <=0.59 solves the problem. I'll check some stuff as well

ShaMan123 commented 2 years ago

I'll release a version soon

ShaMan123 commented 2 years ago

Thanks

ShaMan123 commented 2 years ago

Gave it a closer inspection. It seems that the mathfield resets caret position when value is changed imperatively (using setValue) which is the case for controlled math view. Workaround: Store caret position onContentWillChange and set it onContentDidChange.

ShaMan123 commented 2 years ago

v1.3.2