desmosinc / mathquill

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

Delete sqrt with 'delete' before it, and add 'delete' tests #278

Closed jared-hughes closed 7 months ago

jared-hughes commented 7 months ago

Behavior change

Setup: cursor immediately before a square root, e.g. at the start of a field with latex \sqrt{x}

Before: pressing "delete" (delete-to-the-right) would move the cursor to the right.

After: pressing "delete" (delete-to-the-right) deletes the square root and keeps the content within.

This matches the behavior of pressing "delete" when the cursor is at the far-right of the radix/index/degree of an nthroot.

Implementation notes

It just does the same as typing "Right" then "Backspace" (delete-to-the-left).

I also put some tests for "Delete" since there were previously only tests for "Backspace," added in https://github.com/mathquill/mathquill/pull/453/commits/4a8779f76f9e6c26fc8bb389e9aa5a8f50efe1b7.

jared-hughes commented 7 months ago

Merge blocker (now fixed): Negative behavior change when pressing "delete" before the index of an nthroot: <cursor>\sqrt[3]{5}. PR leaves "35" behind. Old behavior is moving the cursor to the start of the "3".