Skip to content

Commit 92259ba

Browse files
authored
feat(button & stepper): ensure minimum 48x48 hit target for better accessibility (#3522)
* Added hitslop calculation for button * fixed ts error - not sure why it popped now * Updated snapshots with hitslop * Refactor getAccessibleHitSlop to simplify width calculation and improve hit slop logic * Revert "Refactor getAccessibleHitSlop to simplify width calculation and improve hit slop logic" This reverts commit c1b3ba1. * fix(button): rename variable for clarity in getAccessibleHitSlop method
1 parent e65b917 commit 92259ba

File tree

4 files changed

+501
-9
lines changed

4 files changed

+501
-9
lines changed

demo/src/screens/__tests__/__snapshots__/TextFieldScreen.spec.js.snap

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3555,6 +3555,14 @@ exports[`TextField Screen renders screen 1`] = `
35553555
accessible={true}
35563556
collapsable={false}
35573557
focusable={true}
3558+
hitSlop={
3559+
{
3560+
"bottom": 15,
3561+
"left": 0,
3562+
"right": 0,
3563+
"top": 15,
3564+
}
3565+
}
35583566
onClick={[Function]}
35593567
onLayout={[Function]}
35603568
onResponderGrant={[Function]}
@@ -3891,10 +3899,10 @@ exports[`TextField Screen renders screen 1`] = `
38913899
focusable={true}
38923900
hitSlop={
38933901
{
3894-
"bottom": 20,
3895-
"left": 20,
3896-
"right": 20,
3897-
"top": 20,
3902+
"bottom": 7.5,
3903+
"left": 10,
3904+
"right": 10,
3905+
"top": 7.5,
38983906
}
38993907
}
39003908
onClick={[Function]}
@@ -4613,6 +4621,14 @@ exports[`TextField Screen renders screen 1`] = `
46134621
accessible={true}
46144622
collapsable={false}
46154623
focusable={true}
4624+
hitSlop={
4625+
{
4626+
"bottom": 7.5,
4627+
"left": 10,
4628+
"right": 10,
4629+
"top": 7.5,
4630+
}
4631+
}
46164632
onClick={[Function]}
46174633
onLayout={[Function]}
46184634
onResponderGrant={[Function]}

src/components/button/ButtonConstants.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,11 @@ export const MIN_WIDTH = {
2222
LARGE: 90
2323
};
2424

25+
export const SIZE_TO_VERTICAL_HITSLOP = {
26+
[ButtonSize.xSmall]: 30,
27+
[ButtonSize.small]: 25,
28+
[ButtonSize.medium]: 20,
29+
[ButtonSize.large]: 15
30+
} as const;
31+
2532
export const DEFAULT_SIZE = ButtonSize.large;

0 commit comments

Comments
 (0)