Skip to content

feat(renderer): add accessibility actions - #874

Open
patrickkabwe wants to merge 1 commit into
feat/a11y-valuefrom
feat/a11y-actions
Open

patrickkabwe wants to merge 1 commit into
feat/a11y-valuefrom
feat/a11y-actions

Conversation

@patrickkabwe

@patrickkabwe patrickkabwe commented Dec 1, 2026 •

Copy link
Copy Markdown
Collaborator

Part of #838 (step 7). Stacked on #872.

Views take accessibilityActions and onAccessibilityAction. ARIA has no equivalent, so they keep React Native's names.

const actions = [
  { name: 'increment' },
  { name: 'decrement' },
  { name: 'delete', label: 'Delete alarm' },
]

<View
  accessible
  role="slider"
  accessibilityActions={actions}
  onAccessibilityAction={(event) => {
    if (event.actionName === 'increment') setMinutes(minutes + 1)
  }}
/>

The issue left the shape open. The handler receives { actionName } rather than React Native's event.nativeEvent.actionName, since the renderer has no synthetic events. Happy to change it if we want closer React Native compatibility.

  • activate, increment, decrement, longpress, escape, magicTap, expand and collapse map to platform actions. Any other name is a custom action read as its label.
  • iOS: custom names (and longpress, expand, collapse) become UIAccessibilityCustomActions. UIKit asks the view itself for activate, increment, decrement, escape and magicTap, so NativeContainerView (View) and LabelView (Text) override those and forward declared ones, falling back to UIKit otherwise. Other components get custom actions only. The two properties live in their own public extension View because Callback needs a public NitroModules import.
  • Android: the node delegate adds the actions (activate is click, increment is scroll forward, escape is dismiss, ...) and handles them in performAccessibilityAction. Custom actions get ids from 0x3f000000 up, outside framework and app resource ids.
  • Performance: actions are compared by name and label in JS, so an inline array doesn't call native when it's unchanged. Each view gets one native callback that calls the latest JS handler from a WeakMap, so an inline arrow function doesn't call native on every render.
  • Ownership: the native closures capture the callback, not the hybrid view. detachDeletedInstance clears the callback for views that set one, which breaks a cycle through a handler that captures the view. Views without a handler make no extra call on deletion.
  • The Animations example's duration becomes a slider with increment, decrement and a custom "Reset duration" action.

Tested with a temporary self-test, since VoiceOver and TalkBack can't be driven here. It called accessibilityIncrement() twice and then the custom action's handler on iOS, and ViewCompat.performAccessibilityAction with scroll forward twice and then the custom id on Android. On both platforms the duration went from 0.6 to 1.0 and back to 0.6, and the node read as adjustable (AXAdjustable, Android SeekBar). Leaving and reopening the screen, which deletes the view and clears the callback, worked on both.

Re-tested after the move to ARIA names and the rebase onto main: the duration reads as a slider (AXAdjustable, Android SeekBar). The action code itself didn't change, so the self-test wasn't repeated.

@vercel

vercel Bot commented Dec 1, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
nitro-ui-docs Ready Ready Preview Dec 2, 2026 1:35pm UTC

Request Review

@patrickkabwe
patrickkabwe added this pull request to stack #951 December 2, 2026 13:39
@patrickkabwe
patrickkabwe marked this pull request as ready for review December 2, 2026 13:39
@patrickkabwe
patrickkabwe requested a review from hannojg December 2, 2026 13:40
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