fix(math): close inline equation popover on edge ArrowLeft navigation (#5071) - #5073
Closed
Samarth1306w wants to merge 1 commit into
Closed
fix(math): close inline equation popover on edge ArrowLeft navigation (#5071)#5073Samarth1306w wants to merge 1 commit into
Samarth1306w wants to merge 1 commit into
Conversation
…#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
Review or Edit in CodeSandboxOpen the branch in Web Editor • VS Code • Insiders |
🦋 Changeset detectedLatest commit: e226880 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #5071 — Inline equation popover stays open when
ArrowLeftreaches the input edge.Root Cause
When pressing
ArrowLeftorArrowRightat the edge of an inline equation input,useEquationInputcallsselectOutsideEquation, which updates the editor selection to point before or after the equation element. However,selectOutsideEquationomitted callingonClose?.(). Consequently, while editor selection returned to the document, the popover state stayed open. Additionally, inInlineEquationElement, the popover effect only listened to opening conditions without settingopen(false)when the element became deselected.Fix Description
packages/math/src/react/useEquation.ts: InselectOutsideEquation, invokeonClose?.()after moving selection outside the equation node so that popover state is closed cleanly.apps/www/src/registry/ui/equation-node.tsx: InInlineEquationElement's selection effect, add anelse if (!selected)branch to setopen(false)when the equation element is no longer selected.packages/math/src/react/useEquation.spec.tsx: Updated test assertions to verifyonCloseis invoked on edge navigation..changeset/fix-inline-equation-arrowleft-popover.md: Added patch changeset for@platejs/math.Verification
ArrowLeftis pressed,selectOutsideEquation('before')updates selection to before the element AND invokesonClose, cleanly closing the popover.@platejs/math.