Skip to content

Conversation

@jkadamczyk
Copy link
Collaborator

@jkadamczyk jkadamczyk commented Jan 22, 2026

This PR introduces a new native prop for the webview.
The new prop is active: boolean.
When webview is marked active={false} JS alerts will be prevented from being shown to the user.
When webview is marked active={true} or the prop is not passed at all, alerts will show like they normally do.

Summary by CodeRabbit

  • New Features

    • Added an active property to control whether a WebView is considered active.
    • When a WebView is inactive, JavaScript dialogs (alert, confirm, prompt) are suppressed on Android and iOS to avoid prompts from non-active tabs.
  • Chores

    • Added a changelog entry noting the new prop and behavior.

✏️ Tip: You can customize this high-level summary in your review settings.

…siblity of showing alerts if a webview is inactive
@coderabbitai
Copy link

coderabbitai bot commented Jan 22, 2026

📝 Walkthrough

Walkthrough

Adds an active property across platforms that, when false, causes WebView implementations to suppress JavaScript dialogs (alert/confirm/prompt) by short-circuiting native dialog callbacks. The default value is true.

Changes

Cohort / File(s) Summary
TypeScript Types
src/WebViewTypes.ts, src/RNCWebViewNativeComponent.ts
Added active?: boolean to shared props and active?: WithDefault<boolean, true> to native props (default true).
Android WebView Core
android/src/main/java/com/reactnativecommunity/webview/RNCWebView.java, android/src/main/java/com/reactnativecommunity/webview/RNCWebChromeClient.java
Exposed protected mActive with setActive/isActive; added onJsAlert, onJsConfirm, onJsPrompt overrides to cancel/consume JS dialogs when view is inactive.
Android Manager Bridge
android/src/main/java/com/reactnativecommunity/webview/RNCWebViewManagerImpl.kt, android/src/newarch/com/reactnativecommunity/webview/RNCWebViewManager.java, android/src/oldarch/com/reactnativecommunity/webview/RNCWebViewManager.java
Added setActive(viewWrapper, value) in impl and @ReactProp(name = "active") setters in manager(s) to forward the prop to the native view.
iOS Implementation
apple/RNCWebViewImpl.h, apple/RNCWebViewImpl.m
Added active property; initialize to YES and short-circuit WKNavigationDelegate dialog handlers (alert/confirm/text input) to return default responses when inactive.
iOS Manager Bridge
apple/RNCWebViewManager.mm
Added RCT_CUSTOM_VIEW_PROPERTY(active, BOOL, RNCWebViewImpl) to expose the active property to React Native.
Changelog
.changeset/huge-onions-lie.md
Added changeset entry documenting the new active prop and minor version bump.

Sequence Diagram(s)

mermaid
sequenceDiagram
participant JS as React JS
participant RN as RN ViewManager
participant Native as WebView (native)
participant Dialog as WebChromeClient / WK handlers

JS->>RN: set prop active = false
RN->>Native: setActive(false)
JS->>Native: page triggers alert/confirm/prompt
Native->>Dialog: invoke dialog callback
Dialog-->>Native: detect inactive -> cancel/return default
Native-->>JS: default response returned / no native dialog shown
🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 12.50% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title accurately describes the main change: introducing an 'active' prop to prevent inactive webviews from showing JS alerts, which matches the changeset across multiple platform implementations.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

Comment @coderabbitai help to get the list of available commands and usage tips.

@jkadamczyk jkadamczyk requested review from a team January 22, 2026 15:09
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In
`@android/src/main/java/com/reactnativecommunity/webview/RNCWebChromeClient.java`:
- Around line 485-513: Fix the minor typo in the JavaDoc comment above onJsAlert
in RNCWebChromeClient: change "webiew" to "webview" so the comment reads
"Security: Prevent dialogs from being presented when webview is inactive." Leave
the implementation of onJsAlert, onJsConfirm, and onJsPrompt unchanged.

@jkadamczyk jkadamczyk force-pushed the kuba/wp-7127-cross-tab-javascript-execution-in-in-app-browser-enables/webview branch from adf5e8f to ef14789 Compare January 22, 2026 15:12
@jkadamczyk jkadamczyk force-pushed the kuba/wp-7127-cross-tab-javascript-execution-in-in-app-browser-enables/webview branch from ef14789 to 176afdb Compare January 22, 2026 15:13
@jkadamczyk jkadamczyk merged commit e91396a into master Jan 22, 2026
18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants