mathlive icon indicating copy to clipboard operation
mathlive copied to clipboard

Backspace Does Not Fully Remove Definite Integral Symbol ∫ in MathLive Demo

Open andrea78 opened this issue 9 months ago • 2 comments

Description:

When using the MathLive demo page https://cortexjs.io/mathfield/demo, I encountered an issue with the backspace key when trying to delete a definite integral symbol (\int_{lower}^{upper}). After typing a definite integral (e.g., \int_{a}^{b} f(x) ,dx) and using the backspace key to remove the integral operator, the integrand function, and the lower and upper bounds, the integral symbol remains in the expression. The expected behavior is that pressing backspace again should completely remove the remaining integral symbol , but it does not.

Steps to Reproduce:

  1. Go to the MathLive demo page https://cortexjs.io/mathfield/demo.
  2. Using the keyboard, type a definite integral, such as \int_{a}^{b} f(x) ,dx.
  3. Press the backspace key repeatedly to delete the differential dx, the integrand f(x), and the bounds a and b.
  4. Continue pressing backspace after the operator and bounds are removed.

Actual Behavior:

The differential, integrand and bounds are deleted as expected. The integral symbol remains in the expression, and further backspace presses do not remove it.

Expected Behavior:

After deleting the differential, integrand and bounds, pressing backspace again should fully remove the integral symbol , leaving the expression empty.

andrea78 avatar Apr 09 '25 23:04 andrea78

When you create an integral in MathLive, the cursor positions appear to be as follows:

  1. before
  2. lower bound
  3. upper bound
  4. after

Using backspace, the upper and lower bound values can be removed, leaving only the following:

  1. before
  2. after

I think what you want is a special case on delete backward which detects that the last bound is being removed, and removes it without reducing the caret index. This would delete the bound value and place the caret after the integral sign or into the lower bound value.

jgranick avatar Apr 12 '25 00:04 jgranick

Thank you @jgranick for your response and for clarifying how the cursor behaves when deleting an integral in MathLive. I understand that the current behavior leaves the integral symbol after removing the bounds and integrand, with the cursor positioned accordingly.

Your suggestion for a special backspace case sounds like a promising solution. Ideally, after deleting the last bound (or integrand if no bounds remain), a subsequent backspace could remove the integral symbol , placing the cursor either directly before or after the integral expression (e.g., in the "before" or "after" position, depending on context). This would make the deletion process more intuitive and align with the expectation of fully removing the integral expression.

Thank you for considering this suggestion!

andrea78 avatar Apr 12 '25 00:04 andrea78