From 65f22b31cb6d91b93197032c6afad62580d06f13 Mon Sep 17 00:00:00 2001 From: Damiano Plebani Date: Fri, 29 Mar 2024 13:37:55 +0100 Subject: [PATCH 1/2] =?UTF-8?q?Add=20`accessibilityState`=20to=20`Button?= =?UTF-8?q?=E2=80=A6`=20components?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/buttons/ButtonLink.tsx | 1 + src/components/buttons/ButtonOutline.tsx | 1 + src/components/buttons/ButtonSolid.tsx | 5 ++++- src/components/buttons/IconButton.tsx | 1 + src/components/buttons/IconButtonContained.tsx | 3 ++- src/components/buttons/IconButtonSolid.tsx | 1 + src/components/listitems/ListItemSwitch.tsx | 1 + 7 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/components/buttons/ButtonLink.tsx b/src/components/buttons/ButtonLink.tsx index 59cf5e80..23671eb6 100644 --- a/src/components/buttons/ButtonLink.tsx +++ b/src/components/buttons/ButtonLink.tsx @@ -215,6 +215,7 @@ export const ButtonLink = React.forwardRef( accessibilityLabel={accessibilityLabel} accessibilityHint={accessibilityHint} accessibilityRole={"button"} + accessibilityState={{ disabled }} testID={testID} onPress={onPress} onPressIn={onPressIn} diff --git a/src/components/buttons/ButtonOutline.tsx b/src/components/buttons/ButtonOutline.tsx index 0d3c4638..b2b0b25c 100644 --- a/src/components/buttons/ButtonOutline.tsx +++ b/src/components/buttons/ButtonOutline.tsx @@ -331,6 +331,7 @@ export const ButtonOutline = React.forwardRef( accessibilityLabel={accessibilityLabel} accessibilityHint={accessibilityHint} accessibilityRole={"button"} + accessibilityState={{ disabled }} testID={testID} onPress={onPress} onPressIn={onPressIn} diff --git a/src/components/buttons/ButtonSolid.tsx b/src/components/buttons/ButtonSolid.tsx index 7d4d8a0b..20d71081 100644 --- a/src/components/buttons/ButtonSolid.tsx +++ b/src/components/buttons/ButtonSolid.tsx @@ -265,7 +265,10 @@ export const ButtonSolid = React.forwardRef( accessible={true} accessibilityLabel={accessibilityLabel} accessibilityHint={accessibilityHint} - accessibilityState={{ busy: loading }} + accessibilityState={{ + busy: loading, + disabled + }} accessibilityRole={"button"} onPress={handleOnPress} onPressIn={onPressIn} diff --git a/src/components/buttons/IconButton.tsx b/src/components/buttons/IconButton.tsx index e056f2b4..a214fa32 100644 --- a/src/components/buttons/IconButton.tsx +++ b/src/components/buttons/IconButton.tsx @@ -180,6 +180,7 @@ export const IconButton = ({ accessibilityRole={"button"} accessibilityLabel={accessibilityLabel} accessibilityHint={accessibilityHint} + accessibilityState={{ disabled }} // Usability // Add a touchable area around the button hitSlop={8} diff --git a/src/components/buttons/IconButtonContained.tsx b/src/components/buttons/IconButtonContained.tsx index 9a4f6a9a..86da0a85 100644 --- a/src/components/buttons/IconButtonContained.tsx +++ b/src/components/buttons/IconButtonContained.tsx @@ -11,7 +11,6 @@ import Animated, { useSharedValue, withSpring } from "react-native-reanimated"; -import { WithTestID } from "../../utils/types"; import { AnimatedIcon, IOIcons, @@ -26,6 +25,7 @@ import { hexToRgba, useIOExperimentalDesign } from "../../core"; +import { WithTestID } from "../../utils/types"; export type IconButtonContained = WithTestID<{ icon: IOIcons; @@ -215,6 +215,7 @@ export const IconButtonContained = ({ accessibilityLabel={accessibilityLabel} accessibilityHint={accessibilityHint} accessibilityRole={"button"} + accessibilityState={{ disabled }} testID={testID} onPress={onPress} onPressIn={handlePressIn} diff --git a/src/components/buttons/IconButtonSolid.tsx b/src/components/buttons/IconButtonSolid.tsx index fb4afd9b..d05b3b28 100644 --- a/src/components/buttons/IconButtonSolid.tsx +++ b/src/components/buttons/IconButtonSolid.tsx @@ -160,6 +160,7 @@ export const IconButtonSolid = ({ accessibilityLabel={accessibilityLabel} accessibilityHint={accessibilityHint} accessibilityRole={"button"} + accessibilityState={{ disabled }} testID={testID} onPress={onPress} onPressIn={handlePressIn} diff --git a/src/components/listitems/ListItemSwitch.tsx b/src/components/listitems/ListItemSwitch.tsx index 629ef2f2..7b13f6a2 100644 --- a/src/components/listitems/ListItemSwitch.tsx +++ b/src/components/listitems/ListItemSwitch.tsx @@ -98,6 +98,7 @@ export const ListItemSwitch = React.memo( : "no-hide-descendants" } })} + accessibilityState={{ disabled }} > {icon && ( Date: Fri, 5 Apr 2024 11:46:15 +0200 Subject: [PATCH 2/2] Fix typescript error --- src/components/buttons/ButtonOutline.tsx | 2 +- src/components/buttons/ButtonSolid.tsx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/components/buttons/ButtonOutline.tsx b/src/components/buttons/ButtonOutline.tsx index 1c08122c..3f1c0f44 100644 --- a/src/components/buttons/ButtonOutline.tsx +++ b/src/components/buttons/ButtonOutline.tsx @@ -333,7 +333,7 @@ export const ButtonOutline = React.forwardRef( accessibilityLabel={accessibilityLabel || label} accessibilityHint={accessibilityHint} accessibilityRole={"button"} - accessibilityState={{ disabled }} + accessibilityState={{ disabled: disabled || false }} testID={testID} onPress={onPress} onPressIn={onPressIn} diff --git a/src/components/buttons/ButtonSolid.tsx b/src/components/buttons/ButtonSolid.tsx index 0368eba7..baee1f78 100644 --- a/src/components/buttons/ButtonSolid.tsx +++ b/src/components/buttons/ButtonSolid.tsx @@ -267,7 +267,7 @@ export const ButtonSolid = React.forwardRef( accessibilityHint={accessibilityHint} accessibilityState={{ busy: loading, - disabled + disabled: disabled || false }} accessibilityRole={"button"} onPress={handleOnPress}