Skip to content

Ensure that keypad backspaces don't delete entire parentheses nodes at once. #2292

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Mar 11, 2025

Conversation

SonicScrewdriver
Copy link
Contributor

@SonicScrewdriver SonicScrewdriver commented Mar 10, 2025

Summary:

When performing a backspace, our Math Input keypad appears to be deleting the entire contents of a parentheses node, which has been frustrating for our users. This functionality also occurs for logarithmic or trigonometric functions.

For example: hitting backspace on x+(9*9) would result in only x+ remaining.

When reviewing the code it appears that this functionality was set up deliberately, but I have been unable to find the justification or history why.

Given there's no clear reason for this feature, this PR is removing this special logic so that backspaces are handled with the default logic.

For example: hitting backspace on x+(9*9) would result in x+(9*9

Issue: MOB-5576

Test plan:

Manual testing

…eses nodes at once.

When performing a backspace, our Math Input keypad appears to be deleting the entire contents of a parentheses node, which has been frustrating for our users.

For example: hitting backspace on x+(9*9) would result in only x+ remaining.

When reviewing the code it appears that this functionality was set up deliberately, but I have been unable to find the justification or history why.

Given there's no clear reason for this feature, this PR is removing this special logic so that backspaces are handled with the default logic.

For example: hitting backspace on x+(9*9) would result in x+(9*9

Issue: MOB-5576

Test plan:
Manual testing
@SonicScrewdriver SonicScrewdriver self-assigned this Mar 10, 2025
Copy link
Contributor

github-actions bot commented Mar 10, 2025

Size Change: -189 B (-0.02%)

Total Size: 875 kB

Filename Size Change
packages/math-input/dist/es/index.js 77.5 kB -189 B (-0.24%)
ℹ️ View Unchanged
Filename Size
packages/kas/dist/es/index.js 39.7 kB
packages/keypad-context/dist/es/index.js 760 B
packages/kmath/dist/es/index.js 11.1 kB
packages/math-input/dist/es/strings.js 1.79 kB
packages/perseus-core/dist/es/index.js 31.9 kB
packages/perseus-editor/dist/es/index.js 276 kB
packages/perseus-linter/dist/es/index.js 22.8 kB
packages/perseus-score/dist/es/index.js 20.6 kB
packages/perseus/dist/es/index.js 369 kB
packages/perseus/dist/es/strings.js 6.73 kB
packages/pure-markdown/dist/es/index.js 4.14 kB
packages/simple-markdown/dist/es/index.js 13.1 kB

compressed-size-action

Copy link
Contributor

github-actions bot commented Mar 10, 2025

npm Snapshot: Published

Good news!! We've packaged up the latest commit from this PR (419bb9d) and published it to npm. You
can install it using the tag PR2292.

Example:

pnpm add @khanacademy/perseus@PR2292

If you are working in Khan Academy's webapp, you can run:

./dev/tools/bump_perseus_version.sh -t PR2292

@@ -302,64 +302,6 @@ describe("MathQuill", () => {
expect(mathField.getContent()).toEqual("\\left(\\right)");
});

it("should select an expression when deleting from outside (1)", () => {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I simply deleted these tests as we no longer want this unique behaviour. I didn't think there'd be much value in adding new tests to test the default behaviour, but I'm happy to take feedback on this!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe it would be worth adding one test to make sure we don't use the old behavior? Something like it("it doesn't delete whole expressions when using backspace (MOB-5576)", () => {

Were these tests failing after you made your changes?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They were (failing)!

I like including the ticket number in the test - great idea! I'll get that added.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@handeyeco , I've added the test! I added some comments as it's a little confusing with how it works. :)

While we may show the user that we've "deleted" the parens, they both still exist in the code until the expression is fully empty and the backspace is hit one more time to remove the opening parens.

Copy link
Contributor

@handeyeco handeyeco left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense to me, thanks Third!

@SonicScrewdriver SonicScrewdriver merged commit 59b9326 into main Mar 11, 2025
8 checks passed
@SonicScrewdriver SonicScrewdriver deleted the dial-back branch March 11, 2025 22:22
catandthemachines added a commit that referenced this pull request Mar 12, 2025
This PR was opened by the [Changesets
release](https://github.com/changesets/action) GitHub action. When
you're ready to do a release, you can merge this and the packages will
be published to npm automatically. If you're not ready to do a release
yet, that's fine, whenever you add more changesets to main, this PR will
be updated.


# Releases
## @khanacademy/[email protected]

### Minor Changes

- [#2293](#2293)
[`91e30c02c`](91e30c0)
Thanks [@catandthemachines](https://github.com/catandthemachines)! -
Deprecate usage of PerseusErrorOccurred event logging in favor of
PerseusErrorOccurredTI events.

### Patch Changes

- [#2294](#2294)
[`254fa3605`](254fa36)
Thanks [@nishasy](https://github.com/nishasy)! - [Polygon] Show right
angle markers when showAngles is on

- Updated dependencies
\[[`91e30c02c`](91e30c0),
[`59b932619`](59b9326)]:
    -   @khanacademy/[email protected]
    -   @khanacademy/[email protected]
    -   @khanacademy/[email protected]
    -   @khanacademy/[email protected]
    -   @khanacademy/[email protected]
    -   @khanacademy/[email protected]

## @khanacademy/[email protected]

### Minor Changes

- [#2293](#2293)
[`91e30c02c`](91e30c0)
Thanks [@catandthemachines](https://github.com/catandthemachines)! -
Deprecate usage of PerseusErrorOccurred event logging in favor of
PerseusErrorOccurredTI events.

## @khanacademy/[email protected]

### Patch Changes

- Updated dependencies
\[[`91e30c02c`](91e30c0)]:
    -   @khanacademy/[email protected]

## @khanacademy/[email protected]

### Patch Changes

- Updated dependencies
\[[`91e30c02c`](91e30c0)]:
    -   @khanacademy/[email protected]

## @khanacademy/[email protected]

### Patch Changes

- [#2292](#2292)
[`59b932619`](59b9326)
Thanks [@SonicScrewdriver](https://github.com/SonicScrewdriver)! -
Ensure that keypad backspaces don't delete entire parentheses nodes at
once.

- Updated dependencies
\[[`91e30c02c`](91e30c0)]:
    -   @khanacademy/[email protected]
    -   @khanacademy/[email protected]

## @khanacademy/[email protected]

### Patch Changes

- Updated dependencies
\[[`91e30c02c`](91e30c0),
[`254fa3605`](254fa36),
[`59b932619`](59b9326)]:
    -   @khanacademy/[email protected]
    -   @khanacademy/[email protected]
    -   @khanacademy/[email protected]
    -   @khanacademy/[email protected]
    -   @khanacademy/[email protected]
    -   @khanacademy/[email protected]
    -   @khanacademy/[email protected]

## @khanacademy/[email protected]

### Patch Changes

- Updated dependencies
\[[`91e30c02c`](91e30c0)]:
    -   @khanacademy/[email protected]

## @khanacademy/[email protected]

### Patch Changes

- Updated dependencies
\[[`91e30c02c`](91e30c0)]:
    -   @khanacademy/[email protected]
    -   @khanacademy/[email protected]

## @khanacademy/[email protected]

### Patch Changes

- Updated dependencies
\[[`91e30c02c`](91e30c0),
[`59b932619`](59b9326)]:
    -   @khanacademy/[email protected]
    -   @khanacademy/[email protected]
    -   @khanacademy/[email protected]
    -   @khanacademy/[email protected]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants