Skip to content

Add snippets for focus management in Compose #560

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

chikoski
Copy link
Contributor

@chikoski chikoski commented Jul 3, 2025

This pull request add some snippets about focus management

Copy link

snippet-bot bot commented Jul 3, 2025

Here is the summary of changes.

You are about to add 14 region tags.

This comment is generated by snippet-bot.
If you find problems with this result, please file an issue at:
https://github.com/googleapis/repo-automation-bots/issues.
To update this comment, add snippet-bot:force-run label or use the checkbox below:

  • Refresh this comment

Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR introduces a set of Compose snippets demonstrating focus management use-cases and wires them into the existing snippets navigation.

  • Adds new focus snippets covering request focus, focus movement, focus state, focus traversal, and focus targets.
  • Extends the navigation graph (Destination.kt and SnippetsActivity.kt) to include a new FocusExamples screen and its sub-routes.
  • Refactors visibility and imports in FocusSnippets.kt to expose snippet functions and update snippet identifiers.

Reviewed Changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
touchinput/focus/RequestFocus.kt New snippet for requesting focus and redirection
touchinput/focus/MoveFocus.kt New snippet for advancing and clearing focus with ESC
touchinput/focus/FocusedState.kt New snippet for applying ripples based on focus state
touchinput/focus/FocusTraversal.kt New 1D/2D focus traversal examples and overrides
touchinput/focus/FocusTarget.kt New snippet showing which UI elements are focus targets
touchinput/focus/FocusSnippets.kt Hosts all focus snippet UIs, updated visibilities and imports
navigation/Destination.kt Added FocusExamples enum and entries
SnippetsActivity.kt Registered the new FocusExamples routes
Comments suppressed due to low confidence (1)

compose/snippets/src/main/java/com/example/compose/snippets/touchinput/focus/FocusTarget.kt:122

  • This snippet ID is duplicated in InteractiveUiElementIsFocusTargets; consider giving each snippet a unique tag to avoid collisions in generated docs.
        // [START android_compose_touchinput_focus_target_interactive_ui_element]

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.

1 participant