Skip to content

Accessibility labels on Focusable components#193

Open
asgvard wants to merge 1 commit intomainfrom
dmytro/accessibility
Open

Accessibility labels on Focusable components#193
asgvard wants to merge 1 commit intomainfrom
dmytro/accessibility

Conversation

@asgvard
Copy link
Copy Markdown
Collaborator

@asgvard asgvard commented Feb 18, 2026

This PR adds a capability to pass accessibility labels to focusable components so that when they are focused it would call a global onUtterText callback with the concatenated label of all parent nodes + the leaf child node to be spoken by the platform Text To Speech engine.
This library does not implement the TTS itself, it only provides the way of specifying labels and listen to the callback.

The main motivation is the fragmented support of Aria labels on different TV platforms, so when this library is used in the cross-platform project it can provide a unified way of defining accessibility labels and connecting the callback to each platform TTS methods.

Basic usage example is added to App.tsx.

TLDR;

  1. Connect the global onUtterText callback to your platform TTS engine method
  2. Provide accessibilityLabel prop to each useFocusable where you need the element to be accessible
  3. Remember to remove/disable other native HTML aria-based tags, otherwise you might get conflicts between the platform uttering the text from aria tags + this library implementation

TODO:

  • Update docs with the new global method and prop
  • Changelog and version bump before release

@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Feb 18, 2026

⚠️ No Changeset found

Latest commit: 5340eaa

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@asgvard asgvard self-assigned this Feb 18, 2026
Comment on lines +849 to +856
if (
this.focusKey &&
(eventType === DIRECTION_LEFT ||
eventType === DIRECTION_RIGHT ||
eventType === DIRECTION_UP ||
eventType === DIRECTION_DOWN)
) {
this.onArrowRelease(eventType);
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Prettier

Comment on lines +1668 to +1669
* Must be called BEFORE updateParentsHasFocusedChild so we can compare
* the new parent chain against the current one to detect newly entered regions.
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

This implementation makes it fully "stateless" in a sense that we don't need to remember which parents were entered before and which ones are entered for the first time. It just checks the parent tree before updating the focus, so the parents not having focused children NOW are considered as "entering for the first time" regions.

distanceCalculationMethod: 'center'
distanceCalculationMethod: 'center',
onUtterText: (text: string) => {
console.log('onUtterText', text);
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

This will go into the platforms' TTS method.

Copy link
Copy Markdown
Collaborator

@predikament predikament left a comment

Choose a reason for hiding this comment

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

Looks good to me 👍🏻

I guess we want to update the CHANGELOG and README accordingly?

@predikament predikament added the enhancement New feature or request label Feb 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants