mathlive icon indicating copy to clipboard operation
mathlive copied to clipboard

The readonly expression can be replaced and edited as a whole

Open chenqianhe opened this issue 1 year ago • 1 comments

Description

The readonly expression can be replaced and edited as a whole

Steps to Reproduce

  1. go to https://cortexjs.io/mathlive/guides/fill-in-the-blank/ and see the first readonly expression
  2. select all by double-clicking
  3. replace all contents directly by typing on the keyboard

https://github.com/user-attachments/assets/9bb0dcd6-c8fc-46a9-a228-a3478120e33e

Actual Behavior

The readonly expression is replaced

Expected Behavior

Invalid operation

Environment

MathLive version not provided

macOS Chrome Version 127.0.6533.89 (Official Build) (arm64)

chenqianhe avatar Aug 06 '24 03:08 chenqianhe

Cleaned up comment above to make it more readable.

arnog avatar Aug 06 '24 03:08 arnog

I tried doing a bit of digging on this without much luck. For future reference, what I found is that the physical keyboard fails to overwrite the readonly field (as expected) while the virtual keyboard shows the same behaviour reported in this issue. Strangely, pressing Delete on the virtual keyboard does not delete the selection, while typing another key (e.g. a number) does what reported in this issue. The only slightly suspicious thing I found is that inside the function perform in commands.ts, when command == "deleteBackward" COMMANDS[selector].changeContent is set to true (as I would expect) while when command == "insert" (as it is for when the user types a digit), then COMMANDS[selector].changeContent is set to false.

I was not able to understand where, how and why changeContent is set in a way or the other

gamberoillecito avatar Aug 30 '25 21:08 gamberoillecito

Additional comment: in the debugger I changed COMMANDS["insert"].changeContent from false to true and I'm no longer able to reproduce the bug reported in the issue. I was not able though to find where this value is set in the code and I'm still not sure about whether this is the intended meaning of this flag. @arnog do you think this is a valid solution?

gamberoillecito avatar Aug 31 '25 07:08 gamberoillecito