Skip to content

Commit

Permalink
Button: Fix VR in type=submit (#3941)
Browse files Browse the repository at this point in the history
  • Loading branch information
AlbertCarreras authored Jan 16, 2025
1 parent 2cc3d27 commit 55a2252
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 24 deletions.
23 changes: 15 additions & 8 deletions packages/gestalt/src/Button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ const ButtonWithForwardRef = forwardRef<HTMLButtonElement, Props>(function Butto
<button
ref={innerRef}
aria-label={accessibilityLabel}
className={baseTypeClasses}
className={parentButtonClasses}
data-test-id={dataTestId}
disabled={disabled}
name={name}
Expand All @@ -337,17 +337,24 @@ const ButtonWithForwardRef = forwardRef<HTMLButtonElement, Props>(function Butto
onTouchMove={handleTouchMove}
// @ts-expect-error - TS2322 - Type '(arg1: TouchEvent<HTMLDivElement>) => void' is not assignable to type 'TouchEventHandler<HTMLButtonElement>'.
onTouchStart={handleTouchStart}
style={compressStyle || undefined}
style={isInVRExperiment ? compressStyle || undefined : undefined}
// @ts-expect-error - TS2322 - Type '0 | -1 | null' is not assignable to type 'number | undefined'.
tabIndex={disabled ? null : tabIndex}
type="submit"
>
<InternalButtonContent
iconEnd={iconEnd}
size={size}
text={buttonText}
textColor={textColor}
/>
<div className={childrenDivClasses} style={compressStyle || undefined}>
{iconEnd || iconStart ? (
<InternalButtonContent
iconEnd={iconEnd}
iconStart={iconStart}
size={size}
text={buttonText}
textColor={textColor}
/>
) : (
buttonText
)}
</div>
</button>
);
}
Expand Down
12 changes: 4 additions & 8 deletions packages/gestalt/src/__snapshots__/BannerUpsell.test.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ exports[`<BannerUpsell /> message + title + dismissButton + image + form 1`] = `
>
<button
aria-label="Submit button"
className="button inline accessibilityOutline tapTransition md red enabled"
className="button inline accessibilityOutline parentButton"
disabled={false}
onBlur={[Function]}
onClick={[Function]}
Expand All @@ -159,16 +159,12 @@ exports[`<BannerUpsell /> message + title + dismissButton + image + form 1`] = `
type="submit"
>
<div
className="Flex rowGap200 columnGap0 justifyCenter xsDirectionRow xsItemsCenter"
className="button inline accessibilityOutline tapTransition md red enabled childrenDiv"
>
<div
className="FlexItem"
className="inverse alignCenter Text fontSize300 fontWeightSemiBold"
>
<div
className="inverse alignCenter Text fontSize300 fontWeightSemiBold"
>
Submit
</div>
Submit
</div>
</div>
</button>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ exports[`BannerUpsellForm renders 1`] = `
>
<button
aria-label="Submit button"
className="button inline accessibilityOutline tapTransition md red enabled"
className="button inline accessibilityOutline parentButton"
disabled={false}
onBlur={[Function]}
onClick={[Function]}
Expand All @@ -59,16 +59,12 @@ exports[`BannerUpsellForm renders 1`] = `
type="submit"
>
<div
className="Flex rowGap200 columnGap0 justifyCenter xsDirectionRow xsItemsCenter"
className="button inline accessibilityOutline tapTransition md red enabled childrenDiv"
>
<div
className="FlexItem"
className="inverse alignCenter Text fontSize300 fontWeightSemiBold"
>
<div
className="inverse alignCenter Text fontSize300 fontWeightSemiBold"
>
Submit
</div>
Submit
</div>
</div>
</button>
Expand Down

0 comments on commit 55a2252

Please sign in to comment.