Skip to content

TabController - Screen reader page auto focus #3743

New issue

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

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

Already on GitHub? # to your account

Closed
wants to merge 4 commits into from

Conversation

nitzanyiz
Copy link
Collaborator

Description

When a Tab is selected the screen reader should jump the focus to the page.

Changelog

TabController - Screen reader autofocus on selected page

Additional info

MADS-4737

@nitzanyiz nitzanyiz requested a review from Copilot May 27, 2025 11:26
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 implements an auto-focus behavior for the screen reader whenever a Tab is selected. Key changes include adding a new active state (isActive) managed via a ref and useEffect hook, updating the animated reaction callback to trigger lazy loading and state updates, and modifying the accessible property in the Reanimated.View.

Comments suppressed due to low confidence (3)

src/components/tabController/TabPage.tsx:101

  • The variable 'isActive' declared within the useAnimatedStyle callback shadows the state variable 'isActive'. Consider renaming the local variable (e.g., 'isCurrentlyActive') for improved clarity.
const animatedPageStyle = useAnimatedStyle(() => { const isActive = Math.round(currentPage.value) === index; ...

src/components/tabController/TabPage.tsx:85

  • The hard-coded 100ms delay for setting accessibility focus may be fragile on some devices. Consider extracting this value to a configurable constant or adding a comment to clarify the rationale behind its selection.
timeoutId = setTimeout(() => { ... }, 100);

src/components/tabController/TabPage.tsx:122

  • Setting accessible={false} may prevent the element from receiving screen reader focus even after calling AccessibilityInfo.setAccessibilityFocus. Verify if this attribute should instead be set to true or adjusted to support the auto-focus behavior.
<Reanimated.View ref={pageRef} style={_style} testID={testID} accessible={false}>

@nitzanyiz nitzanyiz self-assigned this May 27, 2025
@nitzanyiz nitzanyiz marked this pull request as draft May 28, 2025 08:21
@nitzanyiz nitzanyiz closed this Jun 12, 2025
@nitzanyiz nitzanyiz deleted the feat/accessibility-tabcontroller-autofocus branch June 12, 2025 07:05
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant