desmosinc / mathquill

Magic textboxes where you can type math as easily as writing!
mathquill.com
132 stars 39 forks source link

Dont reset cursor on window blur #276

Closed jared-hughes closed 7 months ago

jared-hughes commented 7 months ago

Alt-tab to a different window or Ctrl+Tab to a different tab, then switch back. Current behavior with resetCursorOnBlur: true (which Desmos has) is to move the cursor to the end of the math field. Now, leave the cursor where it is.

In Desmos: resetCursorOnBlur is used to ensure there's not a different cursor state for each mq field in the expressions list. When the user selects a new field (or clicks away from all fields), the cursor on the old one resets to the end of the field.

Switching to a different tab/window doesn't change which field is selected, so it's okay to leave the cursor where it is.

I don't think this PR can be tested with mathquill's testing framework. focusBlur.test.js handles regular blurs but not window blurs.

mikehaverstock commented 7 months ago

Do you have a knox PR up to test this out? I'd like to play with this some.

jared-hughes commented 7 months ago

https://github.com/desmosinc/knox/pull/15776

mikehaverstock commented 7 months ago

Ok so this makes sense to me that we can detect that we blurred the window and therefore don't reset the cursor position. Where do we put focus back in the mathquill when the window regains focus? I was seeing the mathquill regain focus with the cursor in the same position. That part doesn't make sense to me. It's great. I just don't understand the magic.