Skip to content

Commit

Permalink
fix: stop passing ActionButton props to DOM element (#938)
Browse files Browse the repository at this point in the history
This was throwing a React error in the console.
  • Loading branch information
emccorson committed Jul 23, 2024
1 parent bf07a28 commit 7c7f118
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions packages/components/src/ActionButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -87,16 +87,21 @@ export const ActionButton = ({
size,
borderRadius,
disabled,
...props
outlineColor,
textColor: textColorProp,
backgroundColor: backgroundColorProp,
backgroundHoverColor: backgroundHoverColorProp,
textHoverColor: textHoverColorProp,
as,
...domProps
}: ActionButtonProps<keyof React.ReactHTML>): JSX.Element => {
const outlineColor = props.outlineColor;
const textColor = props.textColor || outlineColor || "black";
const textColor = textColorProp || outlineColor || "black";
const backgroundColor =
props.backgroundColor || (props.outlineColor ? "transparent" : "yellow");
backgroundColorProp || (outlineColor ? "transparent" : "yellow");
const backgroundHoverColor =
props.backgroundHoverColor || props.outlineColor || "black";
backgroundHoverColorProp || outlineColor || "black";
const textHoverColor =
props.textHoverColor || (props.outlineColor ? "black" : backgroundColor);
textHoverColorProp || (outlineColor ? "black" : backgroundColor);

const outlined = !!outlineColor;
const colorString = getDefaultColorString(backgroundColor);
Expand All @@ -107,7 +112,7 @@ export const ActionButton = ({
outlined ? getDefaultColorString(outlineColor) : undefined;

return createElement(
props.as ?? ("href" in props ? "a" : "button"),
as ?? ("href" in domProps ? "a" : "button"),
{
className: twMerge(
actionButtonShape({
Expand All @@ -126,7 +131,7 @@ export const ActionButton = ({
"--outline": outlineColorString,
} as CSSProperties,
disabled,
...props,
...domProps,
},
<>
{icon && (
Expand Down

0 comments on commit 7c7f118

Please sign in to comment.