mirror of
https://github.com/bulwarkmail/native.git
synced 2026-11-04 16:06:41 +00:00
fix: announce buttons as buttons with their disabled and busy state
This commit is contained in:
@@ -15,8 +15,13 @@ interface ButtonProps {
|
|||||||
loading?: boolean;
|
loading?: boolean;
|
||||||
icon?: React.ReactNode;
|
icon?: React.ReactNode;
|
||||||
style?: ViewStyle;
|
style?: ViewStyle;
|
||||||
|
/** Needed for an icon-only button; a text button reads its text. */
|
||||||
|
accessibilityLabel?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Extra touch area so even the small sizes reach a 48 dp target.
|
||||||
|
const HIT_SLOP: Record<ButtonSize, number> = { sm: 6, md: 4, lg: 2, icon: 4 };
|
||||||
|
|
||||||
export default function Button({
|
export default function Button({
|
||||||
variant = 'default',
|
variant = 'default',
|
||||||
size = 'md',
|
size = 'md',
|
||||||
@@ -26,6 +31,7 @@ export default function Button({
|
|||||||
loading = false,
|
loading = false,
|
||||||
icon,
|
icon,
|
||||||
style,
|
style,
|
||||||
|
accessibilityLabel,
|
||||||
}: ButtonProps) {
|
}: ButtonProps) {
|
||||||
const c = useColors();
|
const c = useColors();
|
||||||
const styles = React.useMemo(() => makeStyles(c), [c]);
|
const styles = React.useMemo(() => makeStyles(c), [c]);
|
||||||
@@ -43,6 +49,10 @@ export default function Button({
|
|||||||
]}
|
]}
|
||||||
onPress={onPress}
|
onPress={onPress}
|
||||||
disabled={isDisabled}
|
disabled={isDisabled}
|
||||||
|
hitSlop={HIT_SLOP[size]}
|
||||||
|
accessibilityRole="button"
|
||||||
|
accessibilityLabel={accessibilityLabel}
|
||||||
|
accessibilityState={{ disabled: isDisabled, busy: loading }}
|
||||||
>
|
>
|
||||||
{loading ? (
|
{loading ? (
|
||||||
<ActivityIndicator
|
<ActivityIndicator
|
||||||
|
|||||||
Reference in New Issue
Block a user