fix: suppress WebView JS dialogs when browser screen loses focus#26705
Conversation
|
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. |
🔍 Smart E2E Test Selection
click to see 🤖 AI reasoning detailsE2E Test Selection: BrowserTab is a shared, central component used by virtually all dApp-related test flows. The behavioral change to JS dialog suppression affects:
No performance tests are needed as the change is minimal (one hook call + boolean computation with negligible overhead). Performance Test Selection: |
|
✅ E2E Fixture Validation — Schema is up to date |
|



Description
WebView JS dialogs (alert/confirm/prompt) were only suppressed for inactive tabs, but could still appear on top of modals or other screens drawn over the browser.
This adds useIsFocused to gate dialog visibility on both tab state and screen focus, so dialogs are suppressed whenever the browser screen is not in the foreground.
See recordings and notice that After does not show the alert on top of the confirmation screen
(Seems that GitHub trimmed the video to 8 seconds. The original length is 16 seconds.)
Changelog
CHANGELOG entry: fix: supress js dialogs when page is not focused
Related issues
Fixes: https://github.com/MetaMask/mobile-planning/issues/2312
Manual testing steps
See issue linked above
Screenshots/Recordings
Before
webview.alert.mov
After
webview-no-alert.mov
Pre-merge author checklist
Pre-merge reviewer checklist