Skip to content

Commit c1b3ba1

Browse files
committed
Refactor getAccessibleHitSlop to simplify width calculation and improve hit slop logic
1 parent 772e72e commit c1b3ba1

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/components/button/index.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -351,10 +351,10 @@ class Button extends PureComponent<Props, ButtonState> {
351351

352352
getAccessibleHitSlop() {
353353
const containerStyle = this.getContainerSizeStyle();
354-
const isWidthDefined = containerStyle.width !== undefined || containerStyle.minWidth !== undefined;
355-
const width = containerStyle.width || containerStyle.minWidth || 0;
356-
const widthWithPadding = width + (containerStyle.paddingHorizontal || containerStyle.padding || 0) * 2;
357-
const horizontalHitslop = isWidthDefined ? Math.max(0, (48 - widthWithPadding) / 2) : 10;
354+
const width =
355+
(containerStyle.width || containerStyle.minWidth || 0) +
356+
(containerStyle.paddingHorizontal || containerStyle.padding || 0) * 2;
357+
const horizontalHitslop = width !== 0 ? Math.max(0, (48 - width) / 2) : 10;
358358
const verticalHitslop =
359359
(containerStyle.height
360360
? Math.max(0, 48 - containerStyle.height)

0 commit comments

Comments
 (0)