Skip to content

feat: allow GoogleMap to opt out of keyboard focus traversal - #945

Merged
dkhawk merged 3 commits into
mainfrom
feat/google-map-focusable
Jul 14, 2026
Merged

feat: allow GoogleMap to opt out of keyboard focus traversal#945
dkhawk merged 3 commits into
mainfrom
feat/google-map-focusable

Conversation

@kikoso

@kikoso kikoso commented Jul 14, 2026

Copy link
Copy Markdown
Collaborator

Fixes #938

What

Adds a focusable: Boolean = true parameter to GoogleMap, providing an official way to remove the map from keyboard focus traversal, the API shape requested in #938.

Why

#935 made the map a single keyboard focus stop by unconditionally appending Modifier.focusable() and forcing mapView.isFocusable = true. That's the right default for keyboard accessibility, but it left no way to opt out: caller-side Modifier.focusable(false) or focusProperties { canFocus = false } can't override it, since the library applies its own focus configuration after the caller's modifier and directly on the underlying MapView.

Apps that use the map as a decorative background behind sheets/overlays (with their own zoom/pan controls) need the map out of tab traversal entirely, otherwise keyboard focus visibly lands "behind" the overlaying content.

How

  • focusable = true (default): unchanged behavior from fix: keep maps as single tab focus targets #935. The map is a single tab stop (FOCUS_BEFORE_DESCENDANTS).
  • focusable = false: the Compose .focusable() modifier is omitted, and the MapView is set to isFocusable = false with FOCUS_BLOCK_DESCENDANTS, so neither the map nor its internal controls (zoom buttons, Google logo) receive keyboard focus.
  • Focusability is also re-applied in AndroidView's update block, so changing the value across recompositions takes effect on the live view.

Testing

  • Added nonFocusableMapIsSkippedDuringTabTraversal to GoogleMapFocusTraversalTests: a focusable = false map placed between two buttons, asserting Tab moves focus from the first button directly to the second.
  • :maps-compose:compileDebugKotlin and :maps-app:compileDebugAndroidTestKotlin pass locally.

Note: the parameter is placed after mergeDescendants to group it with the existing accessibility-related parameter.

Adds a focusable parameter to GoogleMap (default true, preserving the
single-tab-stop behavior introduced in #935). When false, the map and
its internal controls are removed from keyboard focus traversal, e.g.
for maps used as decorative backgrounds behind other focusable content.

Fixes #938
kikoso added 2 commits July 14, 2026 10:11
Focus traversal only requires the composed view hierarchy, not loaded
map tiles; waiting on onMapLoaded made the test flaky on CI emulators.
Wait for the map's semantics node instead, matching the existing
traversal test.
Material Buttons are clickable-based and only accept focus in keyboard
mode; requestFocus on them fails in the touch-mode test environment.
Plain Modifier.focusable() elements accept focus in both modes, same
as the map itself.
@googlemaps-bot

Copy link
Copy Markdown
Contributor

Code Coverage

Overall Project 25.95%

There is no coverage information present for the Files changed

@dkhawk
dkhawk merged commit 7049991 into main Jul 14, 2026
13 checks passed
@dkhawk
dkhawk deleted the feat/google-map-focusable branch July 14, 2026 19:51
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.

Allow GoogleMap opt out of keyboard focus traversal

3 participants