Skip to content

Add accessibilityValue support to Button component #14903

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

Merged
merged 2 commits into from
Jul 14, 2025

Conversation

Copilot
Copy link
Contributor

@Copilot Copilot AI commented Jul 14, 2025

Summary

This PR implements support for accessibilityValue prop in the React Native Windows Button component, enabling proper propagation of accessibility values from JavaScript to the native C++ layer.

Problem

The Button component in Button.windows.js was missing support for the accessibilityValue prop and related aria-value* props, which prevented accessibility values from being passed through to the underlying TouchableHighlight component. This was identified in the existing ButtonExample where accessibilityValue={{Text: 'Submit Application'}} was being used but not actually supported by the component.

Changes Made

1. Type Support

  • Added AccessibilityValue import from ./View/ViewAccessibility
  • Added accessibilityValue?: ?AccessibilityValue to ButtonProps type definition
  • Added aria-valuemax, aria-valuemin, aria-valuenow, and aria-valuetext props with proper typing

2. Component Logic

  • Added extraction of accessibilityValue and aria-value* props in component destructuring
  • Implemented _accessibilityValue computation logic that mirrors the View component implementation
  • Added proper fallback logic where aria-value* props take precedence over accessibilityValue object properties

3. Prop Propagation

  • Added accessibilityValue={_accessibilityValue} to TouchableHighlight in both Windows and non-Windows code paths
  • Ensures accessibility values are properly passed to the native layer

4. Example Updates

  • Fixed existing ButtonExample.windows.js to use correct property case (text instead of Text)
  • Added demonstration of aria-value* props usage alongside accessibilityValue

Usage Examples

After this change, Button components now support both forms of accessibility value specification:

// Using accessibilityValue object
<Button
  title="Progress Button"
  accessibilityValue={{
    min: 0,
    max: 100,
    now: 75,
    text: "75 percent complete"
  }}
/>

// Using individual aria-value* props
<Button
  title="Progress Button"
  aria-valuemin={0}
  aria-valuemax={100}
  aria-valuenow={75}
  aria-valuetext="75 percent complete"
/>

Testing

  • Verified syntax with Node.js parser
  • Confirmed type imports are correct and consistent with View component
  • Updated existing ButtonExample to demonstrate the functionality
  • Implementation follows exact same pattern as View.windows.js for consistency

Fixes #14902.


💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.

Co-authored-by: anupriya13 <54227869+anupriya13@users.noreply.github.com>
@Copilot Copilot AI changed the title [WIP] [Button] accessibilityValue is not propogated from JS to CPP Add accessibilityValue support to Button component Jul 14, 2025
@Copilot Copilot AI requested a review from anupriya13 July 14, 2025 08:27
Copilot finished work on behalf of anupriya13 July 14, 2025 08:27
@anupriya13 anupriya13 changed the base branch from main to user/anuverma/accessibilityValueButton July 14, 2025 08:33
@anupriya13 anupriya13 marked this pull request as ready for review July 14, 2025 08:33
@anupriya13 anupriya13 requested a review from a team as a code owner July 14, 2025 08:33
@anupriya13 anupriya13 merged commit 9480d9c into user/anuverma/accessibilityValueButton Jul 14, 2025
1 check passed
iamAbhi-916 pushed a commit that referenced this pull request Jul 16, 2025
* Add accessibilityValue support to Button component (#14903)

* Initial plan

* Add accessibilityValue support to Button.windows.js component

Co-authored-by: anupriya13 <54227869+anupriya13@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: anupriya13 <54227869+anupriya13@users.noreply.github.com>

* Add accessibilityValue support to Button component

* Change files

* Add // Windows Comment

---------

Co-authored-by: Copilot <198982749+Copilot@users.noreply.github.com>
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.

[Button] accessibilityValue is not propogated from JS to CPP
2 participants