Skip to content

regain focus when it gets lost by mistake #161

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Dec 16, 2022
Merged

regain focus when it gets lost by mistake #161

merged 3 commits into from
Dec 16, 2022

Conversation

Rich-Harris
Copy link
Member

@Rich-Harris Rich-Harris commented Dec 16, 2022

closes #150.

There are basically three ways that the editor could lose focus:

  1. the user clicked on the page outside the editor
  2. the user tabbed after hitting the Ctrl-M or Ctrl-Shift-M (on Mac) combo (which temporarily disables focus trapping, I learned today)
  3. the iframe captures it

All we need to do, therefore, is determine whether a focusout event was caused by 1 or 2, and if not, recapture the focus. It seems to work reliably for me

@vercel
Copy link

vercel bot commented Dec 16, 2022

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated
learn-svelte-dev ✅ Ready (Inspect) Visit Preview Dec 16, 2022 at 5:00PM (UTC)

Copy link
Member

@dummdidumm dummdidumm left a comment

Choose a reason for hiding this comment

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

(leaving a comment above the boolean so future selves know what the fuck is going on)

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.

Text input focus sometimes lost on rerender/error
2 participants