feat: allow GoogleMap to opt out of keyboard focus traversal - #945
Merged
Conversation
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.
Contributor
Code Coverage
|
dkhawk
approved these changes
Jul 14, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #938
What
Adds a
focusable: Boolean = trueparameter toGoogleMap, 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 forcingmapView.isFocusable = true. That's the right default for keyboard accessibility, but it left no way to opt out: caller-sideModifier.focusable(false)orfocusProperties { canFocus = false }can't override it, since the library applies its own focus configuration after the caller's modifier and directly on the underlyingMapView.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 theMapViewis set toisFocusable = falsewithFOCUS_BLOCK_DESCENDANTS, so neither the map nor its internal controls (zoom buttons, Google logo) receive keyboard focus.AndroidView'supdateblock, so changing the value across recompositions takes effect on the live view.Testing
nonFocusableMapIsSkippedDuringTabTraversaltoGoogleMapFocusTraversalTests: afocusable = falsemap placed between two buttons, asserting Tab moves focus from the first button directly to the second.:maps-compose:compileDebugKotlinand:maps-app:compileDebugAndroidTestKotlinpass locally.Note: the parameter is placed after
mergeDescendantsto group it with the existing accessibility-related parameter.