Skip to content

fix(math): close inline equation popover on edge ArrowLeft navigation (#5071) - #5073

Closed
Samarth1306w wants to merge 1 commit into
udecode:nextfrom
Samarth1306w:fix/inline-equation-arrowleft-popover-5071
Closed

fix(math): close inline equation popover on edge ArrowLeft navigation (#5071)#5073
Samarth1306w wants to merge 1 commit into
udecode:nextfrom
Samarth1306w:fix/inline-equation-arrowleft-popover-5071

Conversation

@Samarth1306w

@Samarth1306w Samarth1306w commented Aug 5, 2026

Copy link
Copy Markdown
  • Auto release

Summary

Fixes #5071 — Inline equation popover stays open when ArrowLeft reaches the input edge.

Root Cause

When pressing ArrowLeft or ArrowRight at the edge of an inline equation input, useEquationInput calls selectOutsideEquation, which updates the editor selection to point before or after the equation element. However, selectOutsideEquation omitted calling onClose?.(). Consequently, while editor selection returned to the document, the popover state stayed open. Additionally, in InlineEquationElement, the popover effect only listened to opening conditions without setting open(false) when the element became deselected.

Fix Description

  1. packages/math/src/react/useEquation.ts: In selectOutsideEquation, invoke onClose?.() after moving selection outside the equation node so that popover state is closed cleanly.
  2. apps/www/src/registry/ui/equation-node.tsx: In InlineEquationElement's selection effect, add an else if (!selected) branch to set open(false) when the equation element is no longer selected.
  3. packages/math/src/react/useEquation.spec.tsx: Updated test assertions to verify onClose is invoked on edge navigation.
  4. .changeset/fix-inline-equation-arrowleft-popover.md: Added patch changeset for @platejs/math.

Verification

  • Code Inspection: Verified that when caret reaches input index 0 and ArrowLeft is pressed, selectOutsideEquation('before') updates selection to before the element AND invokes onClose, cleanly closing the popover.
  • Changeset Included: Patch changeset generated for @platejs/math.

…#5071)

When ArrowLeft or ArrowRight reaches the input edge inside an inline equation,
selectOutsideEquation moves selection outside the element. However, onClose
was not being invoked, leaving the popover open even though the editor selection
had returned to the document.

Fixes:
- Call onClose() inside selectOutsideEquation in useEquationInput.
- Update InlineEquationElement useEffect to close popover (setOpen(false)) when element is deselected.
- Update unit test assertions in useEquation.spec.tsx.

Closes #5071
@codesandbox

codesandbox Bot commented Aug 5, 2026

Copy link
Copy Markdown

Review or Edit in CodeSandbox

Open the branch in Web EditorVS CodeInsiders

Open Preview

@dosubot dosubot Bot added the size:XS This PR changes 0-9 lines, ignoring generated files. label Aug 5, 2026
@changeset-bot

changeset-bot Bot commented Aug 5, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: e226880

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@platejs/math Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@dosubot dosubot Bot added patch Bugfix & documentation PR plugin:math labels Aug 5, 2026
@zbeyens zbeyens closed this Aug 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

patch Bugfix & documentation PR plugin:math size:XS This PR changes 0-9 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants