Skip to content

[material_ui] Expose modal barrier dismiss semantics for Drawer on Android - #13708

Open
jhomlala wants to merge 2 commits into
flutter:mainfrom
jhomlala:fix/drawer-barrier-android-semantics
Open

jhomlala wants to merge 2 commits into
flutter:mainfrom
jhomlala:fix/drawer-barrier-android-semantics

Conversation

@jhomlala

Copy link
Copy Markdown

When a modal Drawer or NavigationDrawer opens on Android, Android Switch Access users could not dismiss the drawer without selecting a destination inside it.

Root cause

In DrawerControllerState._buildDrawer (packages/material_ui/lib/src/drawer.dart), the modal barrier scrim was explicitly excluded from the semantics tree on Android via excluding: platformHasBackButton:

final bool platformHasBackButton = switch (defaultTargetPlatform) {
  TargetPlatform.android => true,
  ...
};

This exclusion originally existed under the assumption that Android users always use a physical or system Back button to dismiss modals. However, Flutter previously updated ModalBarrier to support dismissing barriers on Android (TargetPlatform.android sets platformSupportsDismissingBarrier = true), allowing Switch Access users to dismiss modal bottom sheets and dialogs via the scrim. DrawerController's custom scrim was not updated.

Fix

  • Remove the obsolete platformHasBackButton check in packages/material_ui/lib/src/drawer.dart.
  • Set excluding: !widget.drawerBarrierDismissible so the dismiss barrier semantics is available on all platforms (including Android) when drawerBarrierDismissible is true (default), and excluded when false.
  • Update drawer_test.dart to verify barrier dismiss semantics on all platform variants, and verify it is excluded when drawerBarrierDismissible is false.
  • Add pending changelog entry.

Fixes flutter/flutter#195050

Pre-Review Checklist

I used AI tooling while working on this, and reviewed and tested all of it myself.

Footnotes

  1. Regular contributors who have demonstrated familiarity with the repository guidelines only need to comment if the PR is not auto-exempted by repo tooling. ↩ ↩2

…droid

Fixes flutter/flutter#195050

DrawerController previously excluded the drawer scrim from the semantics
tree on Android via platformHasBackButton. Flutter updated ModalBarrier
to include the dismiss barrier on Android for Switch Access, but DrawerController's
custom scrim was not updated.

This removes the obsolete Android exclusion and sets excluding directly
to !widget.drawerBarrierDismissible, allowing Android Switch Access users
to dismiss the modal drawer without selecting a destination.
@github-actions github-actions Bot added p: material_ui triage-design Should be looked at in design triage P2 Important issues not at the top of the work list labels Nov 18, 2026

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request exposes modal barrier dismiss semantics for Drawer on Android to support Switch Access by replacing platform-specific checks with a check on widget.drawerBarrierDismissible. Tests have been updated to run across all platforms to reflect this change. The review feedback suggests replacing hardcoded 'Dismiss' strings in the tests with const DefaultMaterialLocalizations().modalBarrierDismissLabel to ensure consistency with the framework's localizations.

…el in drawer tests

Avoid hardcoding 'Dismiss' string in drawer barrier semantics tests.
@jhomlala

Copy link
Copy Markdown
Author

Addressed review feedback in 4c9c489: replaced hardcoded 'Dismiss' strings with const DefaultMaterialLocalizations().modalBarrierDismissLabel in drawer_test.dart.

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

Labels

p: material_ui P2 Important issues not at the top of the work list triage-design Should be looked at in design triage

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[NavigationDrawer / Drawer] Cannot close modal drawer on Android using Switch Access without making a selection

1 participant