Skip to content

Commit

Permalink
Fix Button's compatibility with Google Translate (#2376)
Browse files Browse the repository at this point in the history
  • Loading branch information
connor-baer authored Jan 8, 2024
1 parent 0a19d76 commit dadbde1
Show file tree
Hide file tree
Showing 6 changed files with 91 additions and 74 deletions.
5 changes: 5 additions & 0 deletions .changeset/brave-moles-marry.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@sumup/circuit-ui': patch
---

Improve compatibility of the Button component with Google Translate ([ref](https://github.com/facebook/react/issues/11538#issuecomment-390386520)).
2 changes: 1 addition & 1 deletion packages/circuit-ui/components/Button/Button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ export const Button = forwardRef<any, ButtonProps>(
aria-hidden="true"
/>
)}
{children}
<span>{children}</span>
{TrailingIcon && (
<TrailingIcon
className={classes['trailing-icon']}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
.base > span:last-child > span {
line-height: 0;
}

/* Sizes */
button.s, a.s {
padding: calc(var(--cui-spacings-byte) - var(--cui-border-width-kilo));
Expand Down
2 changes: 1 addition & 1 deletion packages/circuit-ui/components/IconButton/IconButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ export const IconButton = forwardRef<any, IconButtonProps>(
return (
<Button
title={labelString}
className={clsx(classes[size], className)}
className={clsx(classes.base, classes[size], className)}
size={size}
{...props}
ref={ref}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ exports[`Sidebar > should render and match snapshot when open 1`] = `
data-testid="sidebar-backdrop"
/>
<button
class="_base_892426 _focus-visible_73b4bb _m_892426 _secondary_892426 _m_f6dd9a _base_9bf092 circuit-2"
class="_base_892426 _focus-visible_73b4bb _m_892426 _secondary_892426 _base_f6dd9a _m_f6dd9a _base_9bf092 circuit-2"
data-testid="sidebar-close-button"
title="Close sidebar"
type="button"
Expand All @@ -111,23 +111,25 @@ exports[`Sidebar > should render and match snapshot when open 1`] = `
<span
class="_content_892426"
>
<svg
aria-hidden="true"
fill="none"
height="24"
viewBox="0 0 24 24"
width="24"
xmlns="http://www.w3.org/2000/svg"
>
<path
d="M20.71 19.29c.186.19.29.445.29.71a1 1 0 0 1-1 1c-.265 0-.52-.104-.71-.29L12 13.42l-7.29 7.29c-.19.186-.444.29-.71.29a1 1 0 0 1-1-1c0-.265.104-.52.29-.71L10.58 12 3.29 4.71A1.014 1.014 0 0 1 3 4a1 1 0 0 1 1-1c.266 0 .52.104.71.29L12 10.58l7.29-7.29c.19-.186.445-.29.71-.29a1 1 0 0 1 1 1c0 .266-.104.52-.29.71L13.42 12l7.29 7.29z"
fill="currentColor"
/>
</svg>
<span
class="_hide-visually_73b4bb"
>
Close sidebar
<span>
<svg
aria-hidden="true"
fill="none"
height="24"
viewBox="0 0 24 24"
width="24"
xmlns="http://www.w3.org/2000/svg"
>
<path
d="M20.71 19.29c.186.19.29.445.29.71a1 1 0 0 1-1 1c-.265 0-.52-.104-.71-.29L12 13.42l-7.29 7.29c-.19.186-.444.29-.71.29a1 1 0 0 1-1-1c0-.265.104-.52.29-.71L10.58 12 3.29 4.71A1.014 1.014 0 0 1 3 4a1 1 0 0 1 1-1c.266 0 .52.104.71.29L12 10.58l7.29-7.29c.19-.186.445-.29.71-.29a1 1 0 0 1 1 1c0 .266-.104.52-.29.71L13.42 12l7.29 7.29z"
fill="currentColor"
/>
</svg>
<span
class="_hide-visually_73b4bb"
>
Close sidebar
</span>
</span>
</span>
</button>
Expand Down Expand Up @@ -212,7 +214,7 @@ exports[`Sidebar > should render and match the snapshot when closed 1`] = `
data-testid="sidebar-backdrop"
/>
<button
class="_base_892426 _focus-visible_73b4bb _m_892426 _secondary_892426 _m_f6dd9a _base_9bf092 circuit-2"
class="_base_892426 _focus-visible_73b4bb _m_892426 _secondary_892426 _base_f6dd9a _m_f6dd9a _base_9bf092 circuit-2"
data-testid="sidebar-close-button"
title="Close sidebar"
type="button"
Expand All @@ -228,23 +230,25 @@ exports[`Sidebar > should render and match the snapshot when closed 1`] = `
<span
class="_content_892426"
>
<svg
aria-hidden="true"
fill="none"
height="24"
viewBox="0 0 24 24"
width="24"
xmlns="http://www.w3.org/2000/svg"
>
<path
d="M20.71 19.29c.186.19.29.445.29.71a1 1 0 0 1-1 1c-.265 0-.52-.104-.71-.29L12 13.42l-7.29 7.29c-.19.186-.444.29-.71.29a1 1 0 0 1-1-1c0-.265.104-.52.29-.71L10.58 12 3.29 4.71A1.014 1.014 0 0 1 3 4a1 1 0 0 1 1-1c.266 0 .52.104.71.29L12 10.58l7.29-7.29c.19-.186.445-.29.71-.29a1 1 0 0 1 1 1c0 .266-.104.52-.29.71L13.42 12l7.29 7.29z"
fill="currentColor"
/>
</svg>
<span
class="_hide-visually_73b4bb"
>
Close sidebar
<span>
<svg
aria-hidden="true"
fill="none"
height="24"
viewBox="0 0 24 24"
width="24"
xmlns="http://www.w3.org/2000/svg"
>
<path
d="M20.71 19.29c.186.19.29.445.29.71a1 1 0 0 1-1 1c-.265 0-.52-.104-.71-.29L12 13.42l-7.29 7.29c-.19.186-.444.29-.71.29a1 1 0 0 1-1-1c0-.265.104-.52.29-.71L10.58 12 3.29 4.71A1.014 1.014 0 0 1 3 4a1 1 0 0 1 1-1c.266 0 .52.104.71.29L12 10.58l7.29-7.29c.19-.186.445-.29.71-.29a1 1 0 0 1 1 1c0 .266-.104.52-.29.71L13.42 12l7.29 7.29z"
fill="currentColor"
/>
</svg>
<span
class="_hide-visually_73b4bb"
>
Close sidebar
</span>
</span>
</span>
</button>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ exports[`CloseButton > styles > should render and match snapshot when not visibl
}
<button
class="_base_892426 _focus-visible_73b4bb _m_892426 _secondary_892426 _m_f6dd9a _base_9bf092 circuit-0"
class="_base_892426 _focus-visible_73b4bb _m_892426 _secondary_892426 _base_f6dd9a _m_f6dd9a _base_9bf092 circuit-0"
title="Close"
type="button"
>
Expand All @@ -34,23 +34,25 @@ exports[`CloseButton > styles > should render and match snapshot when not visibl
<span
class="_content_892426"
>
<svg
aria-hidden="true"
fill="none"
height="24"
viewBox="0 0 24 24"
width="24"
xmlns="http://www.w3.org/2000/svg"
>
<path
d="M20.71 19.29c.186.19.29.445.29.71a1 1 0 0 1-1 1c-.265 0-.52-.104-.71-.29L12 13.42l-7.29 7.29c-.19.186-.444.29-.71.29a1 1 0 0 1-1-1c0-.265.104-.52.29-.71L10.58 12 3.29 4.71A1.014 1.014 0 0 1 3 4a1 1 0 0 1 1-1c.266 0 .52.104.71.29L12 10.58l7.29-7.29c.19-.186.445-.29.71-.29a1 1 0 0 1 1 1c0 .266-.104.52-.29.71L13.42 12l7.29 7.29z"
fill="currentColor"
/>
</svg>
<span
class="_hide-visually_73b4bb"
>
Close
<span>
<svg
aria-hidden="true"
fill="none"
height="24"
viewBox="0 0 24 24"
width="24"
xmlns="http://www.w3.org/2000/svg"
>
<path
d="M20.71 19.29c.186.19.29.445.29.71a1 1 0 0 1-1 1c-.265 0-.52-.104-.71-.29L12 13.42l-7.29 7.29c-.19.186-.444.29-.71.29a1 1 0 0 1-1-1c0-.265.104-.52.29-.71L10.58 12 3.29 4.71A1.014 1.014 0 0 1 3 4a1 1 0 0 1 1-1c.266 0 .52.104.71.29L12 10.58l7.29-7.29c.19-.186.445-.29.71-.29a1 1 0 0 1 1 1c0 .266-.104.52-.29.71L13.42 12l7.29 7.29z"
fill="currentColor"
/>
</svg>
<span
class="_hide-visually_73b4bb"
>
Close
</span>
</span>
</span>
</button>
Expand All @@ -77,7 +79,7 @@ exports[`CloseButton > styles > should render and match snapshot when visible 1`
}
<button
class="_base_892426 _focus-visible_73b4bb _m_892426 _secondary_892426 _m_f6dd9a _base_9bf092 circuit-0"
class="_base_892426 _focus-visible_73b4bb _m_892426 _secondary_892426 _base_f6dd9a _m_f6dd9a _base_9bf092 circuit-0"
title="Close"
type="button"
>
Expand All @@ -92,23 +94,25 @@ exports[`CloseButton > styles > should render and match snapshot when visible 1`
<span
class="_content_892426"
>
<svg
aria-hidden="true"
fill="none"
height="24"
viewBox="0 0 24 24"
width="24"
xmlns="http://www.w3.org/2000/svg"
>
<path
d="M20.71 19.29c.186.19.29.445.29.71a1 1 0 0 1-1 1c-.265 0-.52-.104-.71-.29L12 13.42l-7.29 7.29c-.19.186-.444.29-.71.29a1 1 0 0 1-1-1c0-.265.104-.52.29-.71L10.58 12 3.29 4.71A1.014 1.014 0 0 1 3 4a1 1 0 0 1 1-1c.266 0 .52.104.71.29L12 10.58l7.29-7.29c.19-.186.445-.29.71-.29a1 1 0 0 1 1 1c0 .266-.104.52-.29.71L13.42 12l7.29 7.29z"
fill="currentColor"
/>
</svg>
<span
class="_hide-visually_73b4bb"
>
Close
<span>
<svg
aria-hidden="true"
fill="none"
height="24"
viewBox="0 0 24 24"
width="24"
xmlns="http://www.w3.org/2000/svg"
>
<path
d="M20.71 19.29c.186.19.29.445.29.71a1 1 0 0 1-1 1c-.265 0-.52-.104-.71-.29L12 13.42l-7.29 7.29c-.19.186-.444.29-.71.29a1 1 0 0 1-1-1c0-.265.104-.52.29-.71L10.58 12 3.29 4.71A1.014 1.014 0 0 1 3 4a1 1 0 0 1 1-1c.266 0 .52.104.71.29L12 10.58l7.29-7.29c.19-.186.445-.29.71-.29a1 1 0 0 1 1 1c0 .266-.104.52-.29.71L13.42 12l7.29 7.29z"
fill="currentColor"
/>
</svg>
<span
class="_hide-visually_73b4bb"
>
Close
</span>
</span>
</span>
</button>
Expand Down

1 comment on commit dadbde1

@vercel
Copy link

@vercel vercel bot commented on dadbde1 Jan 8, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.