mathquill / mathquill

Easily type math in your webapp

Home Page:http://mathquill.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Simulated keystroke doesn't seem to work on delete for a selection

rwmorton opened this issue · comments

Hi there,

Long story short I have done a hack to work around some errors I'm getting with the expression trees so what I'm doing to get around that is I'm getting all the raw latex pre- and post- cursor as well as any selected latex (if any). The source will be at the end of this post.

This hack works fine ONLY IF a single character in the expression is selected (in this case I selected 'y' out of 'xyz'):

WhatsApp Image 2023-01-01 at 18 16 30

It does NOT work for more than one character selected (in this case I selected 'xyz' out of 'abcxyzijk':

WhatsApp Image 2023-01-01 at 18 16 51

As you can see from above it only deletes the first character in the selection?

Here is the latter example as selected in the MathField.

Screenshot from 2023-01-01 18-17-16

Here is the relevant source.

image

Bump 🙏

Hi @rwmorton ,

I have mixed news on this front. We are a bit behind getting this finally merged in, but the great folks at Desmos have been maintaining a fork of mathquill that has a lot of bugfixes and features on it.

I completed a review of the changes, but we have some project hygiene stuff we want to complete before merging it into the master branch, primarily cutting a release from the tip of master first. I'm going to try to push this ahead, as it has been stalled for a couple of months.

In the meantime, you can build the desmos fork of mathquill where this bug appears to be fixed - https://github.com/desmosinc/mathquill

To be clear, this version of the codebase is on its way to becoming the mainline of mathquill, just pushing it over the finish line got stalled a bit. - #947
(note this PR is only part of the desmos work, they have also converted the codebase to typescript as mentioned in the other linked PRs in the description of that one. I recommend building from the desmos main branch linked above. I know it says it is 24 commits behind the master branch, but it was just fixes for our CI system, there aren't functional changes to the core codebase on mainline that aren't in the desmos fork.

Doing a little more testing it appears the environment in which I "reproduced" the issue actually wasn't showing something special about the desmos branch. In the application where I am using mathquill I have a virtual keyboard that suffers from behavior similar to what you are describing, but that appears to be related to the fact that pressing a button on the virtual keyboard makes the mathquill lose focus. There is handling of mathquill inputs tracking their cursor position after they lose focus, so if you tab back to them they will have their cursor position maintained, which is how the virtual keyboard is able to insert new characters at the correct position even after the mathquill loses focus as the button is pressed. This doesn't appear to be happening for a selection.

That being said, somehow the Desmos website does implement this behavior, but the test I was doing that I thought proved the mathquill branch they have is the what makes that possible actually didn't prove that.

I pasted this in the console on the desmos homepage when something was typed into the math input and a selection was made and it was able to delete multiple characters with a virtual backspace press just fine, but this appears to be because focusing the devtools/console does not unfocus the mathinput in the page. This works both on mainline and the desmos fork just fine.

mathquill-bug-mainline-2023-01-05_02.06.15.mp4
mathquill-bug-desmo-fork-2023-01-05_02.05.37.mp4

Thank you very much for the feedback @jaltekruse !