Skip to content

fix: prevent focus stealing from external contenteditable editors#3625

Open
mattConnHarbour wants to merge 1 commit into
mainfrom
sd-3365-fix-focus-stealing
Open

fix: prevent focus stealing from external contenteditable editors#3625
mattConnHarbour wants to merge 1 commit into
mainfrom
sd-3365-fix-focus-stealing

Conversation

@mattConnHarbour
Copy link
Copy Markdown
Contributor

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.

…-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>
@mattConnHarbour mattConnHarbour requested a review from a team as a code owner June 3, 2026 19:35
@linear-code
Copy link
Copy Markdown

linear-code Bot commented Jun 3, 2026

SD-3365

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 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".

Comment on lines +307 to +310
const targetDom = this.#getTargetDom?.();
const targetRoot = targetDom?.closest?.('.presentation-editor') ?? targetDom?.parentElement;
if (targetRoot && !targetRoot.contains(originContentEditable)) {
return null;
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge 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-commenter
Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jun 3, 2026

📦 Preview published: superdoc@1.38.0-pr.3625.1780516654

npm install superdoc@pr-3625

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants