Repository navigation
fix: restore focus after execCommand clipboard fallback (#428) - #461
Merged
presidojay1 merged 1 commit intoNov 19, 2026
Merged
Conversation
👷 Deploy request for stellartickets pending review.Visit the deploys page to approve it
|
|
@Temi-suwa18 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
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.
Summary
The
execCommandfallback incopyToClipboardmoved focus to a temporary off-screen<textarea>and never returned it. When the element was removed infinally, focus fell to<body>, stranding keyboard and screen-reader users who had pressed Enter on the "Copy gate code" button.Changes
src/lib/clipboard.tsdocument.activeElementbefore appending the textarea.aria-hidden="true"andtabIndex = -1on the textarea so it is invisible to assistive technology and unreachable by Tab.textarea.select()totextarea.focus()+setSelectionRange(0, length)— required for iOS Safari to actually select text in the fallback path.previousFocus?.focus?.()infinally, after the textarea is removed.src/lib/clipboard.test.ts<button>, focuses it, callscopyToClipboard, assertsdocument.activeElementis the button again afterwards.activeElementis<body>(the no-op focus path).Closes #428
Closes #429
Closes #430
Closes #431