fix: prevent event propagation on paste and mouse down in rich text e… - #394
Merged
Merged
Conversation
saa938
approved these changes
Sep 3, 2026
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.
Description
Fixes two text-editing bugs reported in #387:
Resolves #387
Practice Questions paste duplication — pasting into the question rich-text editor (and the image caption editor) duplicated the pasted content, sometimes rendering it outside the intended editor box. Root cause: the custom
onPastehandlers calledevent.preventDefault()but notevent.stopPropagation(), so the native paste event still bubbled up to Editor.js's own delegated paste listener on its holder element. That listener only treats<input>/<textarea>as "native" and skips them — it doesn't recognize plaincontentEditabledivs — so it went ahead and inserted the same clipboard content a second time into whatever block/caret Editor.js considered "current," which could differ from the nested editor's own location.Caption hyperlink popover closing immediately — clicking the link button in the caption toolbar closed the popover before the URL field could be focused. Root cause: the toolbar button had no
onMouseDownguard, so the mousedown itself blurred thecontentEditablecaption field before the button'sonClick(which opens the popover) ran. The editor'shandleBlurthen closed the just-opened popover on its next animation frame.Related:
RichTextEditor.tsxfor the Practice Questions body/options andCaptionRichTextEditor.tsxfor image captions.Pull request type
Please check the type of change your PR introduces:
A summary of the change, anything else that will help review this PR
How Has This Been Tested? How can the reviewer test it?
Verified via code inspection/tracing of the event flow and confirmed
tsc --noEmitshows no new type errors introduced by the changes.To test manually:
Bug 1
Bug 2
Checklist