Skip to content

feat(android): add blurBehindRadius to Modal - #60217

Open
kagantemizkan wants to merge 1 commit into
react:mainfrom
kagantemizkan:android-modal-blur-behind
Open

kagantemizkan wants to merge 1 commit into
react:mainfrom
kagantemizkan:android-modal-blur-behind

Conversation

@kagantemizkan

Copy link
Copy Markdown

Summary

Adds an Android-only blurBehindRadius prop (dp) to Modal. When set on a transparent modal, the system blurs the app behind the modal window with the window blur Android has shipped since 12 (WindowManager.LayoutParams.FLAG_BLUR_BEHIND + setBlurBehindRadius). The compositor draws the blur, so there is no snapshot of the content and no per-frame drawing in the app, unlike JS/view based blur libraries that copy the backdrop every frame.

  • Applied in ReactModalHostView.updateProperties, so changing the radius while the modal is open updates the window without recreating the dialog.
  • When the device can't draw cross-window blur (WindowManager.isCrossWindowBlurEnabled is false: no GPU support, tunnel mode, "Allow window-level blurs" turned off, or OEM power saving), the window behind is dimmed instead (FLAG_DIM_BEHIND, 0.5), so the modal is still set apart from what it covers. A addCrossWindowBlurEnabledListener keeps this in sync while the modal is shown and is removed on dismiss.
  • No-op below API 31. iOS is not part of this change (the prop is ignored there).
  • animationType fade/slide and statusBarTranslucent/navigationBarTranslucent keep working.

Naming: the other Android-only Modal props (hardwareAccelerated, statusBarTranslucent, navigationBarTranslucent) and the codegen specs are unprefixed, so this follows that instead of android_*. Happy to rename (e.g. android_blurBehindRadius) if preferred.

Not included (possible follow-up): Window.setBackgroundBlurRadius for blurring the dialog's own background.

Changelog:

[ANDROID] [ADDED] - Add blurBehindRadius prop to Modal to blur the content behind it with the system window blur (Android 12+)

Test Plan:

New RNTester example: Modal → "Modal blur behind" (radius slider 0–80 dp outside and inside the modal, animation type chips).

Tested with RNTester (debug, arm64) on:

  • Xiaomi Redmi Note 14, Android 16 (API 36), MIUI/HyperOS
  • Emulator, Android 17 QPR (SDK 37.2), google_apis_ps16k arm64

Checked on both:

  • Blur shows behind a transparent modal; dumpsys window shows fl=BLUR_BEHIND and blurBehindRadius = radius × density.
  • Dragging the slider inside the open modal changes the blur live (24 → 80 dp → ~0) without recreating the dialog.
  • adb shell settings put global disable_window_blurs 1 while the modal is open: the listener fires, the window switches to DIM_BEHIND; setting it back to 0 restores the blur.
  • animationType fade and slide open and close normally (recorded frame by frame on the Redmi).
  • Rotating to landscape and back with the modal open keeps the blur (emulator; the Redmi blocks rotation from adb).
  • With the radius at 0 the window attributes are left as they were, so modals that don't use the prop take the same path as before (not separately exercised on a device).

Known behavior: the system applies the blur as soon as the window is added and removes it when the exit animation starts, so with fade/slide the blur appears/disappears at once while the modal content animates. This is how window blur-behind works on Android today; animating the radius would need a per-frame window attribute update and is left out of this change.

yarn flow check, eslint, prettier and ktfmt pass.

Screenshots

Before (no modal, Redmi) Blur 80 dp (Redmi, API 36) Window blurs off → dim (Redmi) Blur 24 dp (emulator, SDK 37.2)
redmi-0-example redmi-2-blur80-live redmi-4-blur-disabled-dim emu37-1-blur

Landscape with the modal open (emulator, SDK 37.2):

emu37-3-landscape

Adds an Android-only `blurBehindRadius` prop (dp) to Modal. On Android 12+
the modal window sets FLAG_BLUR_BEHIND and setBlurBehindRadius, so the
system compositor blurs the windows behind it without copying the content.

When cross-window blur is unavailable or turned off, the window behind is
dimmed instead. A cross-window blur listener keeps this in sync while the
modal is shown. Changing the radius updates the open dialog without
recreating it.

Adds a "Modal blur behind" RNTester example with a radius slider.
@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Nov 22, 2026
@facebook-github-tools facebook-github-tools Bot added the Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team. label Nov 22, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant