material-components-android icon indicating copy to clipboard operation
material-components-android copied to clipboard

[MaterialAlertDialog] should not set filterTouchesWhenObscured attribute

Open samlu opened this issue 4 months ago • 3 comments

In the layout\m3expressive_alert_dialog.xml file, it adds android:filterTouchesWhenObscured="true" to the top androidx.appcompat.widget.AlertDialogLayout view.

The filterTouchesWhenObscured attribute should not be added to keep the consistent behavior as the system or AppCompat AlertDialog.

com.google.android.material:material:material 1.14.0-alpha04

layout\m3expressive_alert_dialog.xml

<androidx.appcompat.widget.AlertDialogLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:id="@+id/parentPanel"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:gravity="start|left|top"
    android:orientation="vertical"
    android:clipChildren="true"
    android:filterTouchesWhenObscured="true"> <--- don't add this

samlu avatar Sep 09 '25 03:09 samlu

m3expressive_alert_dialog_title.xml has the same issue.

lib/java/com/google/android/material/dialog/res/layout/m3expressive_alert_dialog_title.xml

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/topPanel"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical"
    android:filterTouchesWhenObscured="true"> <--- don't add this

samlu avatar Sep 09 '25 03:09 samlu

Hi, filterTouchesWhenObscured was added due to https://developer.android.com/privacy-and-security/risks/tapjacking#mitigations.

Is it causing an issue for you?

dsn5ft avatar Sep 09 '25 13:09 dsn5ft

The main reason for my suggestion is to maintain consistent behavior with the standard system and AppCompat AlertDialog, neither of which enables this by default.

If this feature is important to include, I'd suggest adding an API to enable/disable filterTouchesWhenObscured for the material expressive AlertDialog. This would provide the security enhancement without forcing a behavior change on all developers.

samlu avatar Sep 10 '25 01:09 samlu