Skip to content

Conversation

n3ps
Copy link
Contributor

@n3ps n3ps commented Sep 8, 2025

Description

Fixes the Popover so it can toggled by the same element that opened it

Open in GitHub Codespaces

Changelog

CHANGELOG entry: null

Related issues

Fixes:

Manual testing steps

  1. Home screen
  2. Click menu button to open
  3. Click same button to close

Screenshots/Recordings

Before

After

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.

@n3ps n3ps added the team-core-extension-ux Core Extension UX team label Sep 8, 2025
Copy link
Contributor

github-actions bot commented Sep 8, 2025

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.

@github-actions github-actions bot added the size-S label Sep 8, 2025
@metamaskbot
Copy link
Collaborator

metamaskbot commented Sep 8, 2025

✨ Files requiring CODEOWNER review ✨

🫰 @MetaMask/core-platform (2 files, +2 -2)
  • 📁 test/
    • 📁 e2e/
      • 📁 snaps/
        • 📄 test-snap-cronjob-duration.spec.ts +1 -1
        • 📄 test-snap-notification.spec.ts +1 -1

🎨 @MetaMask/design-system-engineers (1 files, +21 -20)
  • 📁 ui/
    • 📁 components/
      • 📁 component-library/
        • 📁 popover/
          • 📄 popover.tsx +21 -20

🧪 @MetaMask/qa (1 files, +7 -2)
  • 📁 test/
    • 📁 e2e/
      • 📁 page-objects/
        • 📁 pages/
          • 📄 header-navbar.ts +7 -2

🖥️ @MetaMask/wallet-ux (1 files, +19 -13)
  • 📁 ui/
    • 📁 components/
      • 📁 multichain/
        • 📁 app-header/
          • 📄 app-header-unlocked-content.tsx +19 -13

@metamaskbot
Copy link
Collaborator

📊 Page Load Benchmark Results

Current Commit: cdf9de2 | Date: 9/8/2025

📄 https://metamask.github.io/test-dapp/

Samples: 100

Summary

  • pageLoadTime-> current mean value: 1.29s (±46ms) 🟡 | historical mean value: 1.31s ⬇️ (historical data)
  • domContentLoaded-> current mean value: 967ms (±44ms) 🟢 | historical mean value: 985ms ⬇️ (historical data)
  • firstContentfulPaint-> current mean value: 87ms (±17ms) 🟢 | historical mean value: 95ms ⬇️ (historical data)
📈 Detailed Results
Metric Mean Std Dev Min Max P95 P99
pageLoadTime 1.29s 46ms 1.25s 1.67s 1.34s 1.67s
domContentLoaded 967ms 44ms 940ms 1.35s 1.01s 1.35s
firstPaint 87ms 17ms 72ms 212ms 116ms 212ms
firstContentfulPaint 87ms 17ms 72ms 212ms 116ms 212ms
largestContentfulPaint 0ms 0ms 0ms 0ms 0ms 0ms

Results generated automatically by MetaMask CI

@metamaskbot
Copy link
Collaborator

Builds ready [cdf9de2]
UI Startup Metrics (1200 ± 71 ms)
PlatformBuildTypePageMetricMean (ms)Min (ms)Max (ms)Std Dev (ms)P 75 (ms)P 95 (ms)
ChromeBrowserifyHomeuiStartup1200107014297112491313
load104693612306510931150
domContentLoaded103993012196610871144
domInteractive16134241627
firstPaint68372122842810591160
backgroundConnect2392252677242254
firstReactRender24164362640
getState14578101934
initialActions60667713
loadScripts80770097765856913
setupStore1163051323
WebpackHomeuiStartup19931519259628322122453
load15971226201722017671915
domContentLoaded15861214199021817581890
domInteractive2012261271448
firstPaint1636950464178294
backgroundConnect3917353533259
firstReactRender86373255787273
getState3443117314265
initialActions62314614
loadScripts15821212197821717551878
setupStore157253241428
FirefoxBrowserifyHomeuiStartup14521292184910915041677
load1251110116398313011390
domContentLoaded1251110116398313011390
domInteractive1063330452114253
firstPaintNaNNaNNaNNaNNaNNaN
backgroundConnect41201402740120
firstReactRender28235443037
getState63405614
initialActions508712313
loadScripts1221107216168512761375
setupStore105578927
WebpackHomeuiStartup16011372213814617091831
load13691158163712414751576
domContentLoaded13691157163712414741576
domInteractive1103236664102277
firstPaintNaNNaNNaNNaNNaNNaN
backgroundConnect31225263641
firstReactRender45367974757
getState63363610
initialActions702022637
loadScripts13461134161312614551554
setupStore105929919
Benchmark value 240 exceeds gate value 10 for chrome browserify home mean backgroundConnect
Benchmark value 25 exceeds gate value 23 for chrome browserify home mean firstReactRender
Benchmark value 6 exceeds gate value 1 for chrome browserify home mean initialActions
Benchmark value 255 exceeds gate value 18 for chrome browserify home p95 backgroundConnect
Benchmark value 34 exceeds gate value 33 for chrome browserify home p95 getState
Benchmark value 13 exceeds gate value 1.2 for chrome browserify home p95 initialActions
Benchmark value 23 exceeds gate value 17 for chrome browserify home p95 setupStore
Benchmark value 35 exceeds gate value 29 for chrome webpack home mean getState
Benchmark value 265 exceeds gate value 195 for chrome webpack home p95 getState
Benchmark value 14 exceeds gate value 7 for chrome webpack home p95 initialActions
Benchmark value 1452 exceeds gate value 1405 for firefox browserify home mean uiStartup
Benchmark value 1252 exceeds gate value 1245 for firefox browserify home mean load
Benchmark value 1252 exceeds gate value 1239 for firefox browserify home mean domContentLoaded
Benchmark value 41 exceeds gate value 25 for firefox browserify home mean backgroundConnect
Benchmark value 29 exceeds gate value 25 for firefox browserify home mean firstReactRender
Benchmark value 6 exceeds gate value 1 for firefox browserify home mean initialActions
Benchmark value 10 exceeds gate value 9 for firefox browserify home mean setupStore
Benchmark value 1677 exceeds gate value 1660 for firefox browserify home p95 uiStartup
Benchmark value 253 exceeds gate value 195 for firefox browserify home p95 domInteractive
Benchmark value 120 exceeds gate value 70 for firefox browserify home p95 backgroundConnect
Benchmark value 13 exceeds gate value 2 for firefox browserify home p95 initialActions
Benchmark value 110 exceeds gate value 100 for firefox webpack home mean domInteractive
Benchmark value 31 exceeds gate value 26 for firefox webpack home mean backgroundConnect
Benchmark value 45 exceeds gate value 38 for firefox webpack home mean firstReactRender
Benchmark value 8 exceeds gate value 1 for firefox webpack home mean initialActions
Benchmark value 277 exceeds gate value 156 for firefox webpack home p95 domInteractive
Benchmark value 57 exceeds gate value 50 for firefox webpack home p95 firstReactRender
Benchmark value 7 exceeds gate value 2 for firefox webpack home p95 initialActions
Sum of mean exceeds: 365ms | Sum of p95 exceeds: 601.8ms
Sum of all benchmark exceeds: 966.8ms

Bundle size diffs [🚨 Warning! Bundle size has increased!]
  • background: 43 Bytes (0%)
  • ui: 36.78 KiB (0.48%)
  • common: 128 Bytes (0%)

@n3ps n3ps force-pushed the n3ps/global-menu-click-target branch from cdf9de2 to b9b1329 Compare September 8, 2025 18:23
@metamaskbot
Copy link
Collaborator

📊 Page Load Benchmark Results

Current Commit: b9b1329 | Date: 9/8/2025

📄 https://metamask.github.io/test-dapp/

Samples: 100

Summary

  • pageLoadTime-> current mean value: 1.29s (±49ms) 🟡 | historical mean value: 1.31s ⬇️ (historical data)
  • domContentLoaded-> current mean value: 966ms (±47ms) 🟢 | historical mean value: 985ms ⬇️ (historical data)
  • firstContentfulPaint-> current mean value: 88ms (±18ms) 🟢 | historical mean value: 95ms ⬇️ (historical data)
📈 Detailed Results
Metric Mean Std Dev Min Max P95 P99
pageLoadTime 1.29s 49ms 1.26s 1.72s 1.36s 1.72s
domContentLoaded 966ms 47ms 939ms 1.39s 1.02s 1.39s
firstPaint 88ms 18ms 72ms 156ms 140ms 156ms
firstContentfulPaint 88ms 18ms 72ms 156ms 140ms 156ms
largestContentfulPaint 0ms 0ms 0ms 0ms 0ms 0ms

Results generated automatically by MetaMask CI

@metamaskbot
Copy link
Collaborator

Builds ready [b9b1329]
UI Startup Metrics (1234 ± 72 ms)
PlatformBuildTypePageMetricMean (ms)Min (ms)Max (ms)Std Dev (ms)P 75 (ms)P 95 (ms)
ChromeBrowserifyHomeuiStartup1234111315057212751363
load106694913256710901195
domContentLoaded105894013166810831188
domInteractive17134861727
firstPaint65174132843510681138
backgroundConnect2442322859249261
firstReactRender2617150152638
getState1454771828
initialActions617910615
loadScripts821702108666845950
setupStore1063451023
WebpackHomeuiStartup20351537256826321972483
load16331232199920817741946
domContentLoaded16231222197620617641927
domInteractive171275121451
firstPaint1706044364203288
backgroundConnect3317322313362
firstReactRender93383326788296
getState234288511537
initialActions8216717723
loadScripts16191218196420517621916
setupStore176292361426
FirefoxBrowserifyHomeuiStartup14401201175311915051700
load1242106015218812941424
domContentLoaded1242106015218812941423
domInteractive1063331346117207
firstPaintNaNNaNNaNNaNNaNNaN
backgroundConnect4021162253996
firstReactRender28234642937
getState838311616
initialActions611922138
loadScripts1213104214938812681395
setupStore11519519927
WebpackHomeuiStartup15561388204113616281822
load13241172165310913991547
domContentLoaded13231172165310913991547
domInteractive103353205895271
firstPaintNaNNaNNaNNaNNaNNaN
backgroundConnect3321113123648
firstReactRender43356154651
getState63586611
initialActions6118122310
loadScripts12991148163110813741500
setupStore11517019920
Benchmark value 245 exceeds gate value 10 for chrome browserify home mean backgroundConnect
Benchmark value 26 exceeds gate value 23 for chrome browserify home mean firstReactRender
Benchmark value 7 exceeds gate value 1 for chrome browserify home mean initialActions
Benchmark value 1196 exceeds gate value 1190 for chrome browserify home p95 load
Benchmark value 1188 exceeds gate value 1180 for chrome browserify home p95 domContentLoaded
Benchmark value 261 exceeds gate value 18 for chrome browserify home p95 backgroundConnect
Benchmark value 15 exceeds gate value 1.2 for chrome browserify home p95 initialActions
Benchmark value 950 exceeds gate value 940 for chrome browserify home p95 loadScripts
Benchmark value 23 exceeds gate value 17 for chrome browserify home p95 setupStore
Benchmark value 8 exceeds gate value 7 for chrome webpack home mean initialActions
Benchmark value 2484 exceeds gate value 2454 for chrome webpack home p95 uiStartup
Benchmark value 23 exceeds gate value 7 for chrome webpack home p95 initialActions
Benchmark value 1441 exceeds gate value 1405 for firefox browserify home mean uiStartup
Benchmark value 1242 exceeds gate value 1239 for firefox browserify home mean domContentLoaded
Benchmark value 40 exceeds gate value 25 for firefox browserify home mean backgroundConnect
Benchmark value 29 exceeds gate value 25 for firefox browserify home mean firstReactRender
Benchmark value 6 exceeds gate value 1 for firefox browserify home mean initialActions
Benchmark value 11 exceeds gate value 9 for firefox browserify home mean setupStore
Benchmark value 1700 exceeds gate value 1660 for firefox browserify home p95 uiStartup
Benchmark value 207 exceeds gate value 195 for firefox browserify home p95 domInteractive
Benchmark value 96 exceeds gate value 70 for firefox browserify home p95 backgroundConnect
Benchmark value 8 exceeds gate value 2 for firefox browserify home p95 initialActions
Benchmark value 104 exceeds gate value 100 for firefox webpack home mean domInteractive
Benchmark value 33 exceeds gate value 26 for firefox webpack home mean backgroundConnect
Benchmark value 43 exceeds gate value 38 for firefox webpack home mean firstReactRender
Benchmark value 6 exceeds gate value 1 for firefox webpack home mean initialActions
Benchmark value 271 exceeds gate value 156 for firefox webpack home p95 domInteractive
Benchmark value 51 exceeds gate value 50 for firefox webpack home p95 firstReactRender
Benchmark value 10 exceeds gate value 2 for firefox webpack home p95 initialActions
Sum of mean exceeds: 331ms | Sum of p95 exceeds: 540.8ms
Sum of all benchmark exceeds: 871.8ms

Bundle size diffs [🚨 Warning! Bundle size has increased!]
  • background: 43 Bytes (0%)
  • ui: 36.59 KiB (0.48%)
  • common: 128 Bytes (0%)

@metamaskbot
Copy link
Collaborator

📊 Page Load Benchmark Results

Current Commit: 61f81d5 | Date: 9/9/2025

📄 https://metamask.github.io/test-dapp/

Samples: 100

Summary

  • pageLoadTime-> current mean value: 1.30s (±50ms) 🟡 | historical mean value: 1.32s ⬇️ (historical data)
  • domContentLoaded-> current mean value: 977ms (±48ms) 🟢 | historical mean value: 994ms ⬇️ (historical data)
  • firstContentfulPaint-> current mean value: 88ms (±13ms) 🟢 | historical mean value: 99ms ⬇️ (historical data)
📈 Detailed Results
Metric Mean Std Dev Min Max P95 P99
pageLoadTime 1.30s 50ms 1.27s 1.76s 1.35s 1.76s
domContentLoaded 977ms 48ms 945ms 1.43s 1.02s 1.43s
firstPaint 88ms 13ms 72ms 168ms 116ms 168ms
firstContentfulPaint 88ms 13ms 72ms 168ms 116ms 168ms
largestContentfulPaint 0ms 0ms 0ms 0ms 0ms 0ms

Results generated automatically by MetaMask CI

@metamaskbot
Copy link
Collaborator

Builds ready [61f81d5]
UI Startup Metrics (1233 ± 67 ms)
PlatformBuildTypePageMetricMean (ms)Min (ms)Max (ms)Std Dev (ms)P 75 (ms)P 95 (ms)
ChromeBrowserifyHomeuiStartup1233113214516712771346
load107296212966711161190
domContentLoaded106495212856711101182
domInteractive17144451727
firstPaint69178122243110801182
backgroundConnect2502392858254265
firstReactRender24165052535
getState1252951424
initialActions40274512
loadScripts822712104066865940
setupStore962731017
WebpackHomeuiStartup19731486242323721262346
load15861198191118417091861
domContentLoaded15781185190018417011849
domInteractive171281121444
firstPaint1595942362171293
backgroundConnect3417329433165
firstReactRender82373456081291
getState195306451424
initialActions62204615
loadScripts15741183188918316981838
setupStore226294521324
FirefoxBrowserifyHomeuiStartup14331243199012714991678
load1237109014998212951361
domContentLoaded1236109014988212941361
domInteractive1053527547111235
firstPaintNaNNaNNaNNaNNaNNaN
backgroundConnect3519167213580
firstReactRender27224752840
getState738711623
initialActions41851038
loadScripts1210107214797912641333
setupStore13417321850
WebpackHomeuiStartup15861377206115216911865
load13531167162912814441587
domContentLoaded13531166162812814431586
domInteractive1066029451101266
firstPaintNaNNaNNaNNaNNaNNaN
backgroundConnect32237693744
firstReactRender44336044651
getState6212269
initialActions401291339
loadScripts13301142160812914241565
setupStore105858921
Benchmark value 1072 exceeds gate value 1070 for chrome browserify home mean load
Benchmark value 1065 exceeds gate value 1061 for chrome browserify home mean domContentLoaded
Benchmark value 251 exceeds gate value 10 for chrome browserify home mean backgroundConnect
Benchmark value 24 exceeds gate value 23 for chrome browserify home mean firstReactRender
Benchmark value 5 exceeds gate value 1 for chrome browserify home mean initialActions
Benchmark value 1182 exceeds gate value 1180 for chrome browserify home p95 domContentLoaded
Benchmark value 1182 exceeds gate value 1180 for chrome browserify home p95 firstPaint
Benchmark value 266 exceeds gate value 18 for chrome browserify home p95 backgroundConnect
Benchmark value 12 exceeds gate value 1.2 for chrome browserify home p95 initialActions
Benchmark value 941 exceeds gate value 940 for chrome browserify home p95 loadScripts
Benchmark value 15 exceeds gate value 7 for chrome webpack home p95 initialActions
Benchmark value 1434 exceeds gate value 1405 for firefox browserify home mean uiStartup
Benchmark value 36 exceeds gate value 25 for firefox browserify home mean backgroundConnect
Benchmark value 28 exceeds gate value 25 for firefox browserify home mean firstReactRender
Benchmark value 5 exceeds gate value 1 for firefox browserify home mean initialActions
Benchmark value 13 exceeds gate value 9 for firefox browserify home mean setupStore
Benchmark value 1678 exceeds gate value 1660 for firefox browserify home p95 uiStartup
Benchmark value 235 exceeds gate value 195 for firefox browserify home p95 domInteractive
Benchmark value 80 exceeds gate value 70 for firefox browserify home p95 backgroundConnect
Benchmark value 8 exceeds gate value 2 for firefox browserify home p95 initialActions
Benchmark value 50 exceeds gate value 27 for firefox browserify home p95 setupStore
Benchmark value 106 exceeds gate value 100 for firefox webpack home mean domInteractive
Benchmark value 32 exceeds gate value 26 for firefox webpack home mean backgroundConnect
Benchmark value 44 exceeds gate value 38 for firefox webpack home mean firstReactRender
Benchmark value 5 exceeds gate value 1 for firefox webpack home mean initialActions
Benchmark value 266 exceeds gate value 156 for firefox webpack home p95 domInteractive
Benchmark value 51 exceeds gate value 50 for firefox webpack home p95 firstReactRender
Benchmark value 9 exceeds gate value 2 for firefox webpack home p95 initialActions
Sum of mean exceeds: 325ms | Sum of p95 exceeds: 486.8ms
Sum of all benchmark exceeds: 811.8ms

Bundle size diffs [🚨 Warning! Bundle size has increased!]
  • background: 206 Bytes (0%)
  • ui: 48.93 KiB (0.64%)
  • common: 148 Bytes (0%)

@n3ps n3ps marked this pull request as ready for review September 9, 2025 02:36
@n3ps n3ps requested review from a team as code owners September 9, 2025 02:36
@n3ps n3ps changed the title fix: Popover toggle via reference element fix: Popover toggle Sep 9, 2025
// Close the popover when the "Esc" key is pressed
if (onPressEscKey) {
onPressEscKey();
useEffect(() => {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

  1. The event handlers where used in the useEffect but not in the deps array

) {
if (onClickOutside) {
onClickOutside();
const handleClickOutside = (event: MouseEvent) => {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

  1. So we move them inside

isOpen &&
popoverRef.current &&
!popoverRef.current.contains(event.target as Node) &&
!referenceElement?.contains(event.target as Node)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

  1. The trigger (reference) element was not being checked

@n3ps n3ps enabled auto-merge September 9, 2025 17:36
@n3ps n3ps requested a review from DDDDDanica September 9, 2025 18:07
cursor[bot]

This comment was marked as outdated.

@metamaskbot
Copy link
Collaborator

📊 Page Load Benchmark Results

Current Commit: 0dc8661 | Date: 9/9/2025

📄 https://metamask.github.io/test-dapp/

Samples: 100

Summary

  • pageLoadTime-> current mean value: 1.28s (±50ms) 🟡 | historical mean value: 1.31s ⬇️ (historical data)
  • domContentLoaded-> current mean value: 961ms (±48ms) 🟢 | historical mean value: 989ms ⬇️ (historical data)
  • firstContentfulPaint-> current mean value: 86ms (±14ms) 🟢 | historical mean value: 94ms ⬇️ (historical data)
📈 Detailed Results
Metric Mean Std Dev Min Max P95 P99
pageLoadTime 1.28s 50ms 1.25s 1.74s 1.33s 1.74s
domContentLoaded 961ms 48ms 936ms 1.42s 999ms 1.42s
firstPaint 86ms 14ms 72ms 144ms 124ms 144ms
firstContentfulPaint 86ms 14ms 72ms 144ms 124ms 144ms
largestContentfulPaint 0ms 0ms 0ms 0ms 0ms 0ms

Results generated automatically by MetaMask CI

@metamaskbot
Copy link
Collaborator

Builds ready [0dc8661]
UI Startup Metrics (1224 ± 66 ms)
PlatformBuildTypePageMetricMean (ms)Min (ms)Max (ms)Std Dev (ms)P 75 (ms)P 95 (ms)
ChromeBrowserifyHomeuiStartup1224111214876612681335
load105993312236210941179
domContentLoaded105192712156210891169
domInteractive17134241722
firstPaint674138118442910811161
backgroundConnect2522392888256268
firstReactRender25176982741
getState1344671526
initialActions41234514
loadScripts80668495161844933
setupStore953641014
WebpackHomeuiStartup19991481314137122012756
load16281191275032817662406
domContentLoaded16171178274632217522386
domInteractive1812116141643
firstPaint1706451076185328
backgroundConnect3417310382960
firstReactRender76353254879177
getState2452805513218
initialActions62416620
loadScripts16111176274331917412382
setupStore146235231328
FirefoxBrowserifyHomeuiStartup13801215181210414361584
load1195105814387812601321
domContentLoaded1195105714387812591321
domInteractive1013425745105229
firstPaintNaNNaNNaNNaNNaNNaN
backgroundConnect3020115143249
firstReactRender27226062839
getState62446612
initialActions3172737
loadScripts1172103714197912391295
setupStore1049615843
WebpackHomeuiStartup15561371211214016281823
load13251152164411813941556
domContentLoaded13251152164411813941556
domInteractive104363275897276
firstPaintNaNNaNNaNNaNNaNNaN
backgroundConnect31219093641
firstReactRender43356044553
getState63213710
initialActions41719413
loadScripts13021136161911913741534
setupStore11519018921
Benchmark value 253 exceeds gate value 10 for chrome browserify home mean backgroundConnect
Benchmark value 26 exceeds gate value 23 for chrome browserify home mean firstReactRender
Benchmark value 5 exceeds gate value 1 for chrome browserify home mean initialActions
Benchmark value 268 exceeds gate value 18 for chrome browserify home p95 backgroundConnect
Benchmark value 14 exceeds gate value 1.2 for chrome browserify home p95 initialActions
Benchmark value 2757 exceeds gate value 2454 for chrome webpack home p95 uiStartup
Benchmark value 2406 exceeds gate value 2030 for chrome webpack home p95 load
Benchmark value 2386 exceeds gate value 2005 for chrome webpack home p95 domContentLoaded
Benchmark value 218 exceeds gate value 195 for chrome webpack home p95 getState
Benchmark value 20 exceeds gate value 7 for chrome webpack home p95 initialActions
Benchmark value 2383 exceeds gate value 1970 for chrome webpack home p95 loadScripts
Benchmark value 31 exceeds gate value 25 for firefox browserify home mean backgroundConnect
Benchmark value 28 exceeds gate value 25 for firefox browserify home mean firstReactRender
Benchmark value 4 exceeds gate value 1 for firefox browserify home mean initialActions
Benchmark value 11 exceeds gate value 9 for firefox browserify home mean setupStore
Benchmark value 229 exceeds gate value 195 for firefox browserify home p95 domInteractive
Benchmark value 7 exceeds gate value 2 for firefox browserify home p95 initialActions
Benchmark value 43 exceeds gate value 27 for firefox browserify home p95 setupStore
Benchmark value 105 exceeds gate value 100 for firefox webpack home mean domInteractive
Benchmark value 31 exceeds gate value 26 for firefox webpack home mean backgroundConnect
Benchmark value 44 exceeds gate value 38 for firefox webpack home mean firstReactRender
Benchmark value 5 exceeds gate value 1 for firefox webpack home mean initialActions
Benchmark value 276 exceeds gate value 156 for firefox webpack home p95 domInteractive
Benchmark value 53 exceeds gate value 50 for firefox webpack home p95 firstReactRender
Benchmark value 13 exceeds gate value 2 for firefox webpack home p95 initialActions
Sum of mean exceeds: 284ms | Sum of p95 exceeds: 1960.8ms
Sum of all benchmark exceeds: 2244.8ms

Bundle size diffs [🚨 Warning! Bundle size has increased!]
  • background: 6.74 KiB (0.15%)
  • ui: 64.17 KiB (0.83%)
  • common: 1.99 KiB (0.03%)

Copy link
Contributor

@mcmire mcmire left a comment

Choose a reason for hiding this comment

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

Are there unit tests for Popover that we need to change here to test for the bug we are fixing here? I guess the changes to the e2e tests covers this.


// This click will close the menu.
await headerNavbar.openThreeDotMenu();
await headerNavbar.mouseClickOnThreeDotMenu();
Copy link
Contributor

Choose a reason for hiding this comment

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

It looks like openThreeDotMenu accounts for differences on Firefox vs. Chrome. Do we not need to do that anymore?

Copy link
Contributor Author

@n3ps n3ps Sep 9, 2025

Choose a reason for hiding this comment

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

The original test had a flaw itself, it called both methods when only 1 click really mattered because of the popover bug

setAccountOptionsMenuOpen((previous) => {
const isMenuOpen = !previous;
if (isMenuOpen) {
trackEvent({
Copy link
Contributor

Choose a reason for hiding this comment

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

Why are we creating a MetaMetrics event in a React state change handler? Shouldn't we do that afterward?

Copy link
Contributor Author

@n3ps n3ps Sep 9, 2025

Choose a reason for hiding this comment

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

@mcmire That is existing prod code - see line 143, tracking whenever the menu opens

Was trying to keep the focus of this PR about fixing the toggle

Copy link
Contributor

Choose a reason for hiding this comment

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

Gotcha. Does this not work?

setAccountOptionsMenuOpen((previous) => !previous);
if (accountOptionsMenuOpen) {
  trackEvent({
    event: MetaMetricsEventName.NavMainMenuOpened,
    category: MetaMetricsEventCategory.Navigation,
    properties: {
      location: 'Home',
    },
  });
}

Or does it make sense to move the tracking into a useEffect?

Copy link
Contributor

Choose a reason for hiding this comment

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

(This is non-blocking, I will let you decide, but just wanted to point it out in case there is a better way to do this)

Copy link
Contributor Author

@n3ps n3ps Sep 9, 2025

Choose a reason for hiding this comment

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

Calling

if (accountOptionsMenuOpen) {
  trackEvent({
    event: MetaMetricsEventName.NavMainMenuOpened,
    category: MetaMetricsEventCategory.Navigation,
    properties: {
      location: 'Home',
    },
  });
}

directly like that will skew the tracking especially knowing the extension has existing excessive re-renders

useEffect might work but again susceptible to re-renders

IMO safest option without a full rewrite of this component and popover is the setState and logically close to the button click event

I mean we could also put events on the Menu component itself when it renders but I think these are for another PR

Copy link
Contributor

Choose a reason for hiding this comment

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

Okay no problem!

@n3ps n3ps requested a review from mcmire September 9, 2025 19:31
Copy link
Contributor

@mcmire mcmire left a comment

Choose a reason for hiding this comment

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

Snaps-related changes LGTM.

Copy link
Contributor

@owencraston owencraston left a comment

Choose a reason for hiding this comment

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

Did not test but the code looks good.

Copy link
Contributor

@ameliejyc ameliejyc left a comment

Choose a reason for hiding this comment

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

Great improvement, thanks for spotting this!

@n3ps n3ps added this pull request to the merge queue Sep 11, 2025
Merged via the queue into main with commit 1edd1ad Sep 11, 2025
276 of 278 checks passed
@n3ps n3ps deleted the n3ps/global-menu-click-target branch September 11, 2025 09:18
@github-actions github-actions bot locked and limited conversation to collaborators Sep 11, 2025
@metamaskbot metamaskbot added the release-13.4.0 Issue or pull request that will be included in release 13.4.0 label Sep 11, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
release-13.4.0 Issue or pull request that will be included in release 13.4.0 size-S team-core-extension-ux Core Extension UX team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

10 participants