Skip to content

fix: clipboard read request issue in sidepanel#40222

Merged
lwin-kyaw merged 4 commits intomainfrom
fix/side-panel-paste
Feb 19, 2026
Merged

fix: clipboard read request issue in sidepanel#40222
lwin-kyaw merged 4 commits intomainfrom
fix/side-panel-paste

Conversation

@lwin-kyaw
Copy link
Contributor

@lwin-kyaw lwin-kyaw commented Feb 19, 2026

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:

  1. Permission prompt suppressed: Chrome does not display the web clipboard-read permission prompt inside extension side panels. navigator.permissions.query() returns state: 'prompt', but calling navigator.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.

  2. Document focus requirement: Chrome's navigator.clipboard.readText() requires document.hasFocus() === true. In the side panel, when the user was last interacting with the main browser view, document.hasFocus() returns false — causing a "NotAllowedError: Document is not focused" error even after clicking the Paste button. Related: crbug.com/1224037, MDN Clipboard.readText() security notes.

Changes:

  • Detect the side panel environment via getEnvironmentType() === ENVIRONMENT_TYPE_SIDEPANEL.
  • Request the clipboardRead extension permission explicitly via browser.permissions.request() (from webextension-polyfill) for both Firefox and Chrome side panel — bypassing the broken web Permissions API prompt.
  • Add a textareaRef to programmatically focus the SRP textarea before calling navigator.clipboard.readText(). Focusing the textarea transfers document focus to the side panel, satisfying Chrome's document.hasFocus() requirement.
  • Add unit tests covering Firefox and Chrome side panel clipboard permission flows.

Ctrl+V / Cmd+V was unaffected because native keyboard paste goes through the browser's input handling, which doesn't require document.hasFocus() or the web permission prompt.

Open in GitHub Codespaces

Changelog

CHANGELOG entry: Fixed the "Paste" button not working in Chrome side panel mode during wallet import

Related issues

Fixes: #40213

Manual testing steps

  1. Open the MetaMask extension in Chrome Side Panel mode
  2. Navigate to account list → "Add Wallet" → "Import a Wallet"
  3. Copy a valid SRP to your system clipboard
  4. While viewing another site in the main browser view (so the side panel does not have focus), click the "Paste" button
  5. Verify the SRP is pasted into the textarea
  6. Repeat step 4 after clicking inside the side panel first — verify it also works
  7. Open MetaMask as a popup and repeat steps 2–5 — verify existing clipboard behavior is unchanged
  8. Open MetaMask in Firefox and repeat steps 2–5 — verify Firefox clipboard behavior is unchanged

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

  • I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed).
  • I confirm that this PR addresses all acceptance criteria described in the ticket it closes and includes the necessary testing evidence such as recordings and or screenshots.

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 clipboardRead via browser.permissions.request() and focusing the SRP textarea (plus window.focus()) before calling navigator.clipboard.readText().

Refactors the paste path into requestPermissionAndReadClipboard(), adds error handling around clipboard reads, and extends unit tests to mock webextension-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.

@github-actions
Copy link
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.

@metamaskbot metamaskbot added the team-onboarding Onboarding team label Feb 19, 2026
@lwin-kyaw lwin-kyaw changed the title Fix/side panel paste fix: clipboard read request issue in sidepanel Feb 19, 2026
@metamaskbotv2
Copy link
Contributor

metamaskbotv2 bot commented Feb 19, 2026

Builds ready [a2b30c3]
UI Startup Metrics (1467 ± 127 ms)
PlatformBuildTypePageMetricMean (ms)Min (ms)Max (ms)Std Dev (ms)P 75 (ms)P 95 (ms)
ChromeBrowserifyStandard HomeuiStartup14671246205712715151674
load12481048172411412911418
domContentLoaded12371041169811012781410
domInteractive2817112182570
firstPaint186701278167223369
backgroundConnect26423943126267303
firstReactRender17113331923
initialActions105113
loadScripts993796142910510261162
setupStore1262751422
numNetworkReqs312290192284
BrowserifyPower User HomeuiStartup17491413226613818091990
load11951063174113111891543
domContentLoaded11791053169912611761494
domInteractive3618187263854
firstPaint1797634474243302
backgroundConnect34330141222358388
firstReactRender24164162635
initialActions107113
loadScripts91579714241249051233
setupStore1764172032
numNetworkReqs55331452255121
WebpackStandard HomeuiStartup89272114001069241096
load758641111393797922
domContentLoaded751636110793791914
domInteractive3217149242797
firstPaint1366638169174292
backgroundConnect29197793246
firstReactRender20134162335
initialActions105112
loadScripts749634109791789906
setupStore1365361422
numNetworkReqs312295202588
WebpackPower User HomeuiStartup1287950223317913781592
load75764713281187421047
domContentLoaded74764113081187301038
domInteractive40201573138134
firstPaint1527272196165301
backgroundConnect17113542948175277
firstReactRender23183532529
initialActions103111
loadScripts74463912891157281027
setupStore1354261521
numNetworkReqs883625547128163
FirefoxBrowserifyStandard HomeuiStartup17541478311325717672269
load14781236287522715121881
domContentLoaded14771236287522715111881
domInteractive98341541154100180
firstPaint------
backgroundConnect64352753166101
firstReactRender14121711416
initialActions102012
loadScripts14481208285322114881773
setupStore208180281745
numNetworkReqs321994202787
BrowserifyPower User HomeuiStartup27842201716953828443454
load16091250581748416012172
domContentLoaded16091250581648416012172
domInteractive11236568104110378
firstPaint------
backgroundConnect322111952278304918
firstReactRender211581112027
initialActions2036322
loadScripts15731221578648115752126
setupStore1248749178120541
numNetworkReqs58271323279124
WebpackStandard HomeuiStartup16921391362036716762088
load14351202336133714301597
domContentLoaded14341202336033714301591
domInteractive101311843179115143
firstPaint------
backgroundConnect59251853462129
firstReactRender15125751521
initialActions103122
loadScripts14071188333833614061517
setupStore2371673415138
numNetworkReqs312089182782
WebpackPower User HomeuiStartup28291979849671129783727
load16431309609053117112379
domContentLoaded16421309609053117112379
domInteractive12529886162104474
firstPaint------
backgroundConnect3441211707287394929
firstReactRender21163142430
initialActions203123
loadScripts15921281606351316902115
setupStore1649787214209684
numNetworkReqs56281233186116
📊 Page Load Benchmark Results

Current Commit: a2b30c3 | Date: 2/19/2026

📄 Localhost MetaMask Test Dapp

Samples: 100

Summary

  • pageLoadTime-> current mean value: 987ms (±45ms) 🟢 | historical mean value: 1.03s ⬇️ (historical data)
  • domContentLoaded-> current mean value: 692ms (±41ms) 🟢 | historical mean value: 726ms ⬇️ (historical data)
  • firstContentfulPaint-> current mean value: 78ms (±13ms) 🟢 | historical mean value: 86ms ⬇️ (historical data)

📈 Detailed Results

Metric Mean Std Dev Min Max P95 P99
pageLoadTime 987ms 45ms 954ms 1.34s 1.04s 1.34s
domContentLoaded 692ms 41ms 668ms 1.01s 733ms 1.01s
firstPaint 78ms 13ms 64ms 188ms 88ms 188ms
firstContentfulPaint 78ms 13ms 64ms 188ms 88ms 188ms
largestContentfulPaint 0ms 0ms 0ms 0ms 0ms 0ms
Bundle size diffs [🚀 Bundle size reduced!]
  • background: 58 Bytes (0%)
  • ui: -1.52 KiB (-0.02%)
  • common: 20 Bytes (0%)

@lwin-kyaw lwin-kyaw requested a review from a team as a code owner February 19, 2026 05:55
Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 2 potential issues.

@metamaskbotv2
Copy link
Contributor

metamaskbotv2 bot commented Feb 19, 2026

Builds ready [04c9475]
UI Startup Metrics (1443 ± 110 ms)
PlatformBuildTypePageMetricMean (ms)Min (ms)Max (ms)Std Dev (ms)P 75 (ms)P 95 (ms)
ChromeBrowserifyStandard HomeuiStartup14431263179911015141643
load1239107214649312931409
domContentLoaded1231106814589112851384
domInteractive2817119192477
firstPaint191711434208223342
backgroundConnect26023530915269289
firstReactRender17113541925
initialActions105113
loadScripts98882812058910401144
setupStore1264451520
numNetworkReqs312289192280
BrowserifyPower User HomeuiStartup17811411272519318242118
load12221093211717512161632
domContentLoaded12051083198716512031603
domInteractive3819197283593
firstPaint210772004242245321
backgroundConnect35030944628364398
firstReactRender25155082842
initialActions104113
loadScripts93780316691589321326
setupStore1786482028
numNetworkReqs57291492555120
WebpackStandard HomeuiStartup90069615301129521076
load7656191219104831928
domContentLoaded7596141208103826921
domInteractive2917134202478
firstPaint1316228959167249
backgroundConnect29195083443
firstReactRender18123662030
initialActions103112
loadScripts7566121200102824919
setupStore1253241320
numNetworkReqs312297212589
WebpackPower User HomeuiStartup1248883184218013331663
load73563511231067301042
domContentLoaded72562911111067211029
domInteractive38181603037119
firstPaint1467232265176277
backgroundConnect17413240253179296
firstReactRender23173742429
initialActions103111
loadScripts72262711001047191020
setupStore1242041418
numNetworkReqs1012026051134219
FirefoxBrowserifyStandard HomeuiStartup16811399260420517152086
load14091175236016214481702
domContentLoaded14081175236016314481702
domInteractive80334216196174
firstPaint------
backgroundConnect64302883466103
firstReactRender14122821517
initialActions102022
loadScripts13801148232215514191640
setupStore188181211635
numNetworkReqs311999202791
BrowserifyPower User HomeuiStartup27752092454539629313520
load15931273251526916762204
domContentLoaded15921273251426916702204
domInteractive12336711135107413
firstPaint------
backgroundConnect339126915250432857
firstReactRender1914103101821
initialActions103122
loadScripts15481255243725715982159
setupStore107874116993561
numNetworkReqs57271383672135
WebpackStandard HomeuiStartup17601400335533017692112
load14671175291125914781626
domContentLoaded14661175291125914781625
domInteractive882919841127145
firstPaint------
backgroundConnect7426160315667138
firstReactRender17135961726
initialActions103122
loadScripts14401154289225714581606
setupStore2471923315100
numNetworkReqs311997172770
WebpackPower User HomeuiStartup27341976425344828833634
load15891268235129118232119
domContentLoaded15891264235029118232119
domInteractive1243276914697523
firstPaint------
backgroundConnect3201151275277296915
firstReactRender22157872429
initialActions203122
loadScripts15491247233027317742032
setupStore129878719288607
numNetworkReqs56261373472126
📊 Page Load Benchmark Results

Current Commit: 04c9475 | Date: 2/19/2026

📄 Localhost MetaMask Test Dapp

Samples: 100

Summary

  • pageLoadTime-> current mean value: 1.06s (±48ms) 🟡 | historical mean value: 1.03s ⬆️ (historical data)
  • domContentLoaded-> current mean value: 743ms (±45ms) 🟢 | historical mean value: 726ms ⬆️ (historical data)
  • firstContentfulPaint-> current mean value: 82ms (±11ms) 🟢 | historical mean value: 86ms ⬇️ (historical data)

📈 Detailed Results

Metric Mean Std Dev Min Max P95 P99
pageLoadTime 1.06s 48ms 1.03s 1.43s 1.07s 1.43s
domContentLoaded 743ms 45ms 722ms 1.10s 756ms 1.10s
firstPaint 82ms 11ms 68ms 176ms 88ms 176ms
firstContentfulPaint 82ms 11ms 68ms 176ms 88ms 176ms
largestContentfulPaint 0ms 0ms 0ms 0ms 0ms 0ms
Bundle size diffs
  • background: 119 Bytes (0%)
  • ui: -728 Bytes (-0.01%)
  • common: 161 Bytes (0%)

@metamaskbotv2
Copy link
Contributor

metamaskbotv2 bot commented Feb 19, 2026

Builds ready [a2b30c3]
UI Startup Metrics (1431 ± 118 ms)
PlatformBuildTypePageMetricMean (ms)Min (ms)Max (ms)Std Dev (ms)P 75 (ms)P 95 (ms)
ChromeBrowserifyStandard HomeuiStartup14311206194211814761643
load12291036161510112671424
domContentLoaded12201033160310212631400
domInteractive2816103192578
firstPaint168691194133222332
backgroundConnect25823737817261286
firstReactRender18123841927
initialActions106113
loadScripts981792136510110171156
setupStore1374861520
numNetworkReqs312289192283
BrowserifyPower User HomeuiStartup17641408228815517962123
load12011089174414111871601
domContentLoaded11861081173613811711579
domInteractive3520153223587
firstPaint1777638980262296
backgroundConnect34030239822354387
firstReactRender24156072737
initialActions106112
loadScripts92382414231359041299
setupStore1773771932
numNetworkReqs58351522457120
WebpackStandard HomeuiStartup840668111196904997
load71959793690777879
domContentLoaded71359292990773873
domInteractive2715121202379
firstPaint1156127851141210
backgroundConnect26176592844
firstReactRender18123861930
initialActions103112
loadScripts71158992789771866
setupStore1374571332
numNetworkReqs3122104212588
WebpackPower User HomeuiStartup1295971175516013911604
load76167411571157531084
domContentLoaded75266611471147441078
domInteractive38181793335124
firstPaint16869724111203350
backgroundConnect17313636145182261
firstReactRender23174242530
initialActions102111
loadScripts74966411361117421069
setupStore1256561316
numNetworkReqs963727251135159
FirefoxBrowserifyStandard HomeuiStartup16601399284522916712131
load13991176246719114201693
domContentLoaded13981176246619114201692
domInteractive8533103410391146
firstPaint------
backgroundConnect62312453063110
firstReactRender13111511415
initialActions102122
loadScripts13681151242618313921601
setupStore197174281536
numNetworkReqs3219101212794
BrowserifyPower User HomeuiStartup27772254371536429443586
load15811273239926416502147
domContentLoaded15801273239926416492147
domInteractive12835675128109404
firstPaint------
backgroundConnect3281181019268368929
firstReactRender19146781924
initialActions203122
loadScripts15421237235625416212105
setupStore1119781166101498
numNetworkReqs59261403378130
WebpackStandard HomeuiStartup16811441310520017191963
load1413123118469714671582
domContentLoaded1413123018459714661581
domInteractive972930958130214
firstPaint------
backgroundConnect60262173764161
firstReactRender16126561525
initialActions102012
loadScripts1389121717409114371553
setupStore207154291369
numNetworkReqs311992182772
WebpackPower User HomeuiStartup27472018430942829233604
load15811285262626817362131
domContentLoaded15801280262526817352131
domInteractive141311140178101584
firstPaint------
backgroundConnect3091151100245305913
firstReactRender21165252430
initialActions213122
loadScripts15291263250523816961962
setupStore1818777227299695
numNetworkReqs59262273882126
📊 Page Load Benchmark Results

Current Commit: a2b30c3 | Date: 2/19/2026

📄 Localhost MetaMask Test Dapp

Samples: 100

Summary

  • pageLoadTime-> current mean value: 1.05s (±40ms) 🟡 | historical mean value: 1.03s ⬆️ (historical data)
  • domContentLoaded-> current mean value: 724ms (±36ms) 🟢 | historical mean value: 726ms ⬇️ (historical data)
  • firstContentfulPaint-> current mean value: 80ms (±12ms) 🟢 | historical mean value: 86ms ⬇️ (historical data)

📈 Detailed Results

Metric Mean Std Dev Min Max P95 P99
pageLoadTime 1.05s 40ms 1.03s 1.34s 1.08s 1.34s
domContentLoaded 724ms 36ms 704ms 998ms 742ms 998ms
firstPaint 80ms 12ms 64ms 180ms 88ms 180ms
firstContentfulPaint 80ms 12ms 64ms 180ms 88ms 180ms
largestContentfulPaint 0ms 0ms 0ms 0ms 0ms 0ms
Bundle size diffs [🚀 Bundle size reduced!]
  • background: 58 Bytes (0%)
  • ui: -1.52 KiB (-0.02%)
  • common: 20 Bytes (0%)

@lwin-kyaw lwin-kyaw enabled auto-merge February 19, 2026 08:05
@metamaskbotv2
Copy link
Contributor

metamaskbotv2 bot commented Feb 19, 2026

Builds ready [17bb4b1]
UI Startup Metrics (1447 ± 104 ms)
PlatformBuildTypePageMetricMean (ms)Min (ms)Max (ms)Std Dev (ms)P 75 (ms)P 95 (ms)
ChromeBrowserifyStandard HomeuiStartup14471271183610414861637
load1245108416089712831431
domContentLoaded1238107615999512781413
domInteractive2917112192579
firstPaint218741465254226366
backgroundConnect26223933814268289
firstReactRender18123431923
initialActions104112
loadScripts99283213459310331163
setupStore1262541620
numNetworkReqs312289202285
BrowserifyPower User HomeuiStartup2984147210794212426279407
load13041125183714113571565
domContentLoaded12831107177613413341558
domInteractive3620150223789
firstPaint239791713228280346
backgroundConnect987309820614116593713
firstReactRender25175672739
initialActions104112
loadScripts1013849150613110541288
setupStore1575571826
numNetworkReqs78311392392120
WebpackStandard HomeuiStartup89972012771019731092
load76063395895829919
domContentLoaded75362894794824911
domInteractive3017116202581
firstPaint1276738261165231
backgroundConnect28205573144
firstReactRender2112204192235
initialActions103112
loadScripts75162694493822906
setupStore1262741421
numNetworkReqs312290192584
WebpackPower User HomeuiStartup1273868250226913141577
load75265612951137471029
domContentLoaded74164912711137341023
domInteractive43211643040122
firstPaint1587254888179314
backgroundConnect2041321262201171309
firstReactRender22174352332
initialActions102111
loadScripts73864812621117321015
setupStore1353351520
numNetworkReqs1053722943138178
FirefoxBrowserifyStandard HomeuiStartup16741455251318617042059
load14081207215914514571630
domContentLoaded14071202215914514561630
domInteractive79332264195142
firstPaint------
backgroundConnect60331682259110
firstReactRender14112421416
initialActions102112
loadScripts13811187212214214311582
setupStore168139161545
numNetworkReqs312099192788
BrowserifyPower User HomeuiStartup27672132795063129213472
load15931333632851915951953
domContentLoaded15931333632851915951953
domInteractive16352728132176425
firstPaint------
backgroundConnect3581281333272400976
firstReactRender19146081926
initialActions2154523
loadScripts15491301628251615471919
setupStore15014846191153516
numNetworkReqs80261643590159
WebpackStandard HomeuiStartup17791475326031618162113
load15111247282928415241746
domContentLoaded15101246282928415241746
domInteractive111291477145132193
firstPaint------
backgroundConnect63272313568131
firstReactRender16122831625
initialActions1013122
loadScripts14841219279728214951707
setupStore176128171550
numNetworkReqs311992172775
WebpackPower User HomeuiStartup28692050890882829713634
load16311325397441716182415
domContentLoaded16301324397441716182415
domInteractive185491754224180641
firstPaint------
backgroundConnect4331125922624517899
firstReactRender221588102431
initialActions205123
loadScripts15931299394241015832279
setupStore16012824193197596
numNetworkReqs84302304384170
📊 Page Load Benchmark Results

Current Commit: 17bb4b1 | Date: 2/19/2026

📄 Localhost MetaMask Test Dapp

Samples: 100

Summary

  • pageLoadTime-> current mean value: 1.03s (±45ms) 🟡 | historical mean value: 1.03s ⬆️ (historical data)
  • domContentLoaded-> current mean value: 727ms (±43ms) 🟢 | historical mean value: 723ms ⬆️ (historical data)
  • firstContentfulPaint-> current mean value: 80ms (±12ms) 🟢 | historical mean value: 85ms ⬇️ (historical data)

📈 Detailed Results

Metric Mean Std Dev Min Max P95 P99
pageLoadTime 1.03s 45ms 1.01s 1.40s 1.06s 1.40s
domContentLoaded 727ms 43ms 704ms 1.08s 745ms 1.08s
firstPaint 80ms 12ms 60ms 176ms 92ms 176ms
firstContentfulPaint 80ms 12ms 60ms 176ms 92ms 176ms
largestContentfulPaint 0ms 0ms 0ms 0ms 0ms 0ms
Bundle size diffs [🚀 Bundle size reduced!]
  • background: 58 Bytes (0%)
  • ui: -1.52 KiB (-0.02%)
  • common: 20 Bytes (0%)

@lwin-kyaw lwin-kyaw added this pull request to the merge queue Feb 19, 2026
Merged via the queue into main with commit 74dd5ed Feb 19, 2026
177 checks passed
@lwin-kyaw lwin-kyaw deleted the fix/side-panel-paste branch February 19, 2026 09:05
@github-actions github-actions bot locked and limited conversation to collaborators Feb 19, 2026
@metamaskbot metamaskbot added the release-13.20.0 Issue or pull request that will be included in release 13.20.0 label Feb 19, 2026
@chaitanyapotti chaitanyapotti removed the request for review from a team February 19, 2026 09:14
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

release-13.20.0 Issue or pull request that will be included in release 13.20.0 size-M team-onboarding Onboarding team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Paste" button non-functional in side-panel mode during "Add New Wallet" flow

5 participants