Skip to content

fix(emcn): a modal over a native surface takes keys as soon as it takes focus - #10393

Merged
waleedlatif1 merged 3 commits into
stagingfrom
fix/desktop-dialog-escape
Nov 25, 2026
Merged

waleedlatif1 merged 3 commits into
stagingfrom
fix/desktop-dialog-escape

Conversation

@waleedlatif1

@waleedlatif1 waleedlatif1 commented Nov 25, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

  • On desktop, a modal opened over a native surface (the browser panel's Leave page? prompt) blocks keyboard input until the native view is hidden. The modal moved focus to its default button as soon as it was ready, but the block was only lifted on the following animation frame. A key pressed in that gap went to a focused button that ignored it.
  • This caused the intermittent browser-page-dialogs desktop-e2e failure "dialog … was showing when Escape was pressed": Stay was focused, Escape was sent, and the blocking listener dropped it before the frame that would have lifted the block.
  • The modal gate now holds the block, commits readiness synchronously (flushSync) so focus moves into the dialog, and lifts the block right after. Focus and keyboard input now become available at the same moment. Custom takeover surfaces (useNativeSurfaceOcclusionReady) keep the next-frame release.

Evidence

An instrumented run of the step (8 tries in one CI shard) timed renderer events. On the failing try, Stay took focus at t=10268ms and Escape reached the window's capture listener at t=10281ms. The block was lifted after that keydown, in the same millisecond, and the key never reached the document. The page wasn't loading, the shell window and webContents had focus, the page view's before-input-event saw no Escape, and the dialog requestId never changed. With the fix, 12/12 tries passed, and the block lifted 0–3ms after Stay took focus, always before the key.

Type of Change

  • Bug fix

Testing

  • modal.test.tsx: the control that holds focus once the modal is ready now gets the very next key. This fails on the pre-fix modal (key blocked) and passes with the fix.
  • desktop-e2e: the existing "Escape keeps the draft and returns typing to the page" step presses Escape right after Stay is focused. That's the end-to-end regression check.
  • browser-panel-occlusion.test.ts passes.

Checklist

  • Code follows project conventions
  • Temporary e2e instrumentation removed before the final commit

🤖 Generated with Claude Code

@vercel

vercel Bot commented Nov 25, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated
docs Skipped Skipped Nov 25, 2026 12:57am UTC

Request Review

@waleedlatif1 waleedlatif1 changed the title fix(desktop): Escape on the Leave dialog reaches the modal fix(emcn): a modal over a native surface takes keys as soon as it takes focus Nov 25, 2026
@waleedlatif1
waleedlatif1 marked this pull request as ready for review November 25, 2026 00:58
@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@greptile

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@cubic-dev-ai review this PR

@cubic-dev-ai

cubic-dev-ai Bot commented Nov 25, 2026

Copy link
Copy Markdown
Contributor

@cubic-dev-ai review this PR

@waleedlatif1 I have started the AI code review. It will take a few minutes to complete.

@greptile-apps

greptile-apps Bot commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge; no actionable issues were found.

Summary

The modal now accepts keyboard input immediately after readiness commits and focus moves inside it.

  • Native-surface modals pass the first key to their focused control.

Reviews (1) · Last reviewed commit: "test(desktop): drop the Escape-step inst..." · Reviewed by Greptile

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

No issues found across 2 files

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.

Turn on auto-fix | Re-trigger cubic

@waleedlatif1
waleedlatif1 merged commit 05b5b4c into staging Nov 25, 2026
96 checks passed
@waleedlatif1
waleedlatif1 deleted the fix/desktop-dialog-escape branch November 25, 2026 01:38

This branch was previously deployed

1 inactive deployment
Preview — d3155f9f Deployed Nov 25, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant