From e762d8b5356dc5d5e2c7b4e72358c92ba5226836 Mon Sep 17 00:00:00 2001 From: Andrew Holloway Date: Thu, 26 Sep 2024 15:09:51 -0500 Subject: [PATCH] fix(Button): apply external styles when disabled (#2060) - apply passed in class names to disabled wrapper, not the actual button --- src/components/Button/Button.stories.tsx | 6 +-- src/components/Button/Button.tsx | 6 ++- .../Button/__snapshots__/Button.test.tsx.snap | 42 +++++++++---------- .../__snapshots__/SearchBar.test.ts.snap | 4 +- 4 files changed, 30 insertions(+), 28 deletions(-) diff --git a/src/components/Button/Button.stories.tsx b/src/components/Button/Button.stories.tsx index a2f81dfcd..4d8451417 100644 --- a/src/components/Button/Button.stories.tsx +++ b/src/components/Button/Button.stories.tsx @@ -43,13 +43,13 @@ export const DefaultRanks: Story = { render: (args) => { return (
- - -
diff --git a/src/components/Button/Button.tsx b/src/components/Button/Button.tsx index 76f40b1e0..3c332baef 100644 --- a/src/components/Button/Button.tsx +++ b/src/components/Button/Button.tsx @@ -124,7 +124,7 @@ export const Button = forwardRef( rank && styles[`button--${rank}`], size && styles[`button--${size}`], variant && styles[`button--variant-${variant}`], - className, + !isDisabled && className, ); const buttonContentClassName = clsx( @@ -186,7 +186,9 @@ export const Button = forwardRef( // Wrap the button in a simple SPAN to allow for adding the not-allowed cursor return isDisabled ? ( - {coreButton} + + {coreButton} + ) : ( coreButton ); diff --git a/src/components/Button/__snapshots__/Button.test.tsx.snap b/src/components/Button/__snapshots__/Button.test.tsx.snap index ada3371b1..d6b3eedc6 100644 --- a/src/components/Button/__snapshots__/Button.test.tsx.snap +++ b/src/components/Button/__snapshots__/Button.test.tsx.snap @@ -5,7 +5,7 @@ exports[`