Skip to content

Fix FAB accessibility issue with TalkBack#20401

Open
Mahakbajpai wants to merge 2 commits intoankidroid:mainfrom
Mahakbajpai:fix-fab-accessibility
Open

Fix FAB accessibility issue with TalkBack#20401
Mahakbajpai wants to merge 2 commits intoankidroid:mainfrom
Mahakbajpai:fix-fab-accessibility

Conversation

@Mahakbajpai
Copy link

@Mahakbajpai Mahakbajpai commented Mar 5, 2026

Purpose / Description

Fixed an accessibility bug where the "Add FAB" functionality does not work when TalkBack is enabled. The FloatingActionButton was receiving focus but not handling the ACTION_CLICK event properly for TalkBack users, and it was also failing to announce its state changes (menu opened/menu closed) to visually impaired users.

Fixes

[Accessibility] Add FAB doesn't work when talkback is enabled #20379

Approach

  • Added AccessibilityDelegateCompat to DeckPickerFloatingActionMenu to explicitly handle TalkBack ACTION_CLICK events on the fabMain button.
  • Added announceForAccessibility calls (using explicit localized string resources fab_menu_opened and fab_menu_closed in 02-strings.xml) to explicitly tell TalkBack users when the FAB menu opens and closes.
  • Cleaned up the PR commit history to only include the relevant fixed changes.

How Has This Been Tested?

Tested manually with TalkBack enabled.

  1. Verified the FAB now reads its label properly.
  2. Verified that double-tapping (the standard TalkBack click gesture) activates the menu or adds a note depending on whether the FAB is open.
  3. Verified the app accurately announces "Menu opened" and "Menu closed" when toggling the FAB states.
    Ran testPlayDebugUnitTest locally without regressions.

Learning (optional, can help others)

  • TalkBack intercepting touch events requires AccessibilityDelegateCompat to pass an explicit ACTION_CLICK when relying on custom touch handlers.
  • Dynamic visual state changes to Floating Action Buttons (such as unrolling a menu) should announce their state via announceForAccessibility to ensure screen-reader users understand what visual changes just took place on-screen.

Checklist

Please, go through these checks before submitting the PR.

  • You have a descriptive commit message with a short title (first line, max 50 chars).
  • You have commented your code, particularly in hard-to-understand areas
  • You have performed a self-review of your own code
  • UI changes: include screenshots of all affected screens (in particular showing any new or changed strings)
  • UI Changes: You have tested your change using the Google Accessibility Scanner

@Mahakbajpai
Copy link
Author

@criticalAY sir I created a PR. Please review it.

@KT-1114
Copy link

KT-1114 commented Mar 5, 2026

Hi @Mahakbajpai, this is not a review. It looks like you have added the fix on top of another fixes you made. The commits d066013 and cd6454e are not related to this PR. I can help you manage git and learn, you can reach out to me anytime.

Also, I have made the fix for this issue in my PR #20334. So I tried checking out your solution and I think you should announce the state change of the menu. By this I mean after the FAB is opened talkback should announce something which acknowledges user that something has changed on the screen and my focus is now pointing to something else.

Added AccessibilityDelegateCompat to DeckPickerFloatingActionMenu to correctly handle TalkBack ACTION_CLICK events.
@Mahakbajpai Mahakbajpai force-pushed the fix-fab-accessibility branch from e4156ca to dd9ba8c Compare March 6, 2026 06:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants