diff --git a/src/helpers/__tests__/accessiblity.test.tsx b/src/helpers/__tests__/accessiblity.test.tsx
index 6fda22d4..dd277c59 100644
--- a/src/helpers/__tests__/accessiblity.test.tsx
+++ b/src/helpers/__tests__/accessiblity.test.tsx
@@ -2,7 +2,7 @@ import React from 'react';
import { Pressable, Switch, Text, TextInput, TouchableOpacity, View } from 'react-native';
import { isHiddenFromAccessibility, isInaccessible, render, screen } from '../..';
-import { computeAriaLabel, isAccessibilityElement } from '../accessibility';
+import { computeAriaDisabled, computeAriaLabel, isAccessibilityElement } from '../accessibility';
describe('isHiddenFromAccessibility', () => {
test('returns false for accessible elements', () => {
@@ -278,11 +278,11 @@ describe('isHiddenFromAccessibility', () => {
test('has isInaccessible alias', () => {
expect(isInaccessible).toBe(isHiddenFromAccessibility);
});
-});
-test('is not triggered for element with "aria-modal" prop', () => {
- render();
- expect(isHiddenFromAccessibility(screen.getByTestId('subject'))).toBe(false);
+ test('is not triggered for element with "aria-modal" prop', () => {
+ render();
+ expect(isHiddenFromAccessibility(screen.getByTestId('subject'))).toBe(false);
+ });
});
describe('isAccessibilityElement', () => {
@@ -408,3 +408,71 @@ describe('computeAriaLabel', () => {
expect(computeAriaLabel(screen.getByTestId('subject'))).toEqual('External Label');
});
});
+
+describe('computeAriaDisabled', () => {
+ test('supports basic usage', () => {
+ render(
+
+
+
+
+
+
+ ,
+ );
+
+ expect(computeAriaDisabled(screen.getByTestId('default'))).toBe(false);
+ expect(computeAriaDisabled(screen.getByTestId('disabled'))).toBe(true);
+ expect(computeAriaDisabled(screen.getByTestId('disabled-false'))).toBe(false);
+ expect(computeAriaDisabled(screen.getByTestId('disabled-by-state'))).toBe(true);
+ expect(computeAriaDisabled(screen.getByTestId('disabled-false-by-state'))).toBe(false);
+ });
+
+ test('supports TextInput', () => {
+ render(
+
+
+
+
+ ,
+ );
+
+ expect(computeAriaDisabled(screen.getByTestId('default'))).toBe(false);
+ expect(computeAriaDisabled(screen.getByTestId('editable'))).toBe(false);
+ expect(computeAriaDisabled(screen.getByTestId('editable-false'))).toBe(true);
+ });
+
+ test('supports Button', () => {
+ render(
+
+
+ Default Button
+
+
+ Disabled Button
+
+
+ Disabled False Button
+
+ ,
+ );
+
+ expect(computeAriaDisabled(screen.getByTestId('default'))).toBe(false);
+ expect(computeAriaDisabled(screen.getByTestId('disabled'))).toBe(true);
+ expect(computeAriaDisabled(screen.getByTestId('disabled-false'))).toBe(false);
+ });
+
+ test('supports Text', () => {
+ render(
+
+ Default Text
+ Disabled Text
+ ARIA Disabled Text
+ ,
+ );
+
+ expect(computeAriaDisabled(screen.getByText('Default Text'))).toBe(false);
+ expect(computeAriaDisabled(screen.getByText('Disabled Text'))).toBe(true);
+ expect(computeAriaDisabled(screen.getByText('ARIA Disabled Text'))).toBe(true);
+ });
+});
diff --git a/src/helpers/accessibility.ts b/src/helpers/accessibility.ts
index 3f38cd0c..95ab9166 100644
--- a/src/helpers/accessibility.ts
+++ b/src/helpers/accessibility.ts
@@ -209,6 +209,11 @@ export function computeAriaDisabled(element: ReactTestInstance): boolean {
}
const { props } = element;
+
+ if (isHostText(element) && props.disabled) {
+ return true;
+ }
+
return props['aria-disabled'] ?? props.accessibilityState?.disabled ?? false;
}