fix: clipboard read request issue in sidepanel#40222
Merged
Conversation
Contributor
|
CLA Signature Action: All authors have signed the CLA. You may need to manually re-run the blocking PR check if it doesn't pass in a few minutes. |
Contributor
Builds ready [a2b30c3]
UI Startup Metrics (1467 ± 127 ms)
📊 Page Load Benchmark ResultsCurrent Commit: 📄 Localhost MetaMask Test DappSamples: 100 Summary
📈 Detailed Results
Bundle size diffs [🚀 Bundle size reduced!]
|
Contributor
Builds ready [04c9475]
UI Startup Metrics (1443 ± 110 ms)
📊 Page Load Benchmark ResultsCurrent Commit: 📄 Localhost MetaMask Test DappSamples: 100 Summary
📈 Detailed Results
Bundle size diffs
|
04c9475 to
a2b30c3
Compare
Contributor
Builds ready [a2b30c3]
UI Startup Metrics (1431 ± 118 ms)
📊 Page Load Benchmark ResultsCurrent Commit: 📄 Localhost MetaMask Test DappSamples: 100 Summary
📈 Detailed Results
Bundle size diffs [🚀 Bundle size reduced!]
|
chaitanyapotti
approved these changes
Feb 19, 2026
smgv
approved these changes
Feb 19, 2026
tuna1207
approved these changes
Feb 19, 2026
Contributor
Builds ready [17bb4b1]
UI Startup Metrics (1447 ± 104 ms)
📊 Page Load Benchmark ResultsCurrent Commit: 📄 Localhost MetaMask Test DappSamples: 100 Summary
📈 Detailed Results
Bundle size diffs [🚀 Bundle size reduced!]
|
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Description
Fixes the "Paste" button being non-functional in Chrome's side panel mode during the "Add New Wallet" → "Import a Wallet" flow.
Root cause: Two Chrome limitations with the Clipboard API in the side panel context:
Permission prompt suppressed: Chrome does not display the web
clipboard-readpermission prompt inside extension side panels.navigator.permissions.query()returnsstate: 'prompt', but callingnavigator.clipboard.readText()throws "permission denied" without ever showing the prompt. This is a known Chrome behavior with the Async Clipboard API in non-standard document contexts.Document focus requirement: Chrome's
navigator.clipboard.readText()requiresdocument.hasFocus() === true. In the side panel, when the user was last interacting with the main browser view,document.hasFocus()returnsfalse— causing a"NotAllowedError: Document is not focused"error even after clicking the Paste button. Related: crbug.com/1224037, MDN Clipboard.readText() security notes.Changes:
getEnvironmentType() === ENVIRONMENT_TYPE_SIDEPANEL.clipboardReadextension permission explicitly viabrowser.permissions.request()(fromwebextension-polyfill) for both Firefox and Chrome side panel — bypassing the broken web Permissions API prompt.textareaRefto programmatically focus the SRP textarea before callingnavigator.clipboard.readText(). Focusing the textarea transfers document focus to the side panel, satisfying Chrome'sdocument.hasFocus()requirement.Ctrl+V/Cmd+Vwas unaffected because native keyboard paste goes through the browser's input handling, which doesn't requiredocument.hasFocus()or the web permission prompt.Changelog
CHANGELOG entry: Fixed the "Paste" button not working in Chrome side panel mode during wallet import
Related issues
Fixes: #40213
Manual testing steps
Screenshots/Recordings
Before
After
Clicking the Paste button in the side panel correctly pastes the SRP from the clipboard.
Screen.Recording.2026-02-19.at.2.09.35.PM.mov
Pre-merge author checklist
Pre-merge reviewer checklist
Note
Medium Risk
Touches clipboard-permission and focus behavior during wallet import; mistakes could break paste UX across environments, though the change is localized and covered by new tests.
Overview
Fixes the SRP import “Paste” button in Chrome side panel by treating side panel like Firefox: explicitly requesting
clipboardReadviabrowser.permissions.request()and focusing the SRP textarea (pluswindow.focus()) before callingnavigator.clipboard.readText().Refactors the paste path into
requestPermissionAndReadClipboard(), adds error handling around clipboard reads, and extends unit tests to mockwebextension-polyfill/getEnvironmentType()and cover both Firefox and side panel behaviors (including textarea focusing).Written by Cursor Bugbot for commit 17bb4b1. This will update automatically on new commits. Configure here.