fix: prevent focus stealing from external contenteditable editors#3625
fix: prevent focus stealing from external contenteditable editors#3625mattConnHarbour wants to merge 1 commit into
Conversation
…-3365) SuperDoc's PresentationInputBridge was intercepting keyboard events from external TipTap/ProseMirror editors on the same page. Now checks if events originate from a contenteditable outside SuperDoc's DOM tree before intercepting. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 377fa9a6b8
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| const targetDom = this.#getTargetDom?.(); | ||
| const targetRoot = targetDom?.closest?.('.presentation-editor') ?? targetDom?.parentElement; | ||
| if (targetRoot && !targetRoot.contains(originContentEditable)) { | ||
| return null; |
There was a problem hiding this comment.
Do not exclude SuperDoc's sibling hidden editors
When the active target is a header/footer or note story editor, its ProseMirror DOM lives in a hidden host appended under document.body, while the stale body editor is in a different hidden host sibling. In that real setup targetDom.closest('.presentation-editor') is null and the fallback targetDom.parentElement is only the active hidden host, so this check treats the stale SuperDoc editor as “external” and returns before rerouting. That breaks the stale-focus handoff this method exists for, letting input continue into the wrong hidden editor instead of the active story surface.
Useful? React with 👍 / 👎.
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
|
📦 Preview published: npm install superdoc@pr-3625 |
SuperDoc's PresentationInputBridge was intercepting keyboard events from external editors on the same page. Now checks if events originate from a contenteditable outside SuperDoc's DOM tree before intercepting.