Skip to content

Commit

Permalink
Make the buttons default to 'type="button"' to prevent form submissio…
Browse files Browse the repository at this point in the history
…ns on button click (if not specified otherwise)
  • Loading branch information
ikusteu committed May 2, 2023
1 parent 3cd9b5d commit a4b8992
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 13 deletions.
30 changes: 17 additions & 13 deletions packages/ui/src/Button/Button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,21 +46,25 @@ const Button: React.FC<ButtonProps> = ({
children
);

return React.createElement(as, { ...props, className, disabled }, [
startAdornment && (
<div key="start-adornment" className="h-5 shrink-0">
{startAdornment}
</div>
),
return React.createElement(
as,
{ type: "button", ...props, className, disabled },
[
startAdornment && (
<div key="start-adornment" className="h-5 shrink-0">
{startAdornment}
</div>
),

content,
content,

endAdornment && (
<div key="end-adornment" className="h-5 shrink-0">
{endAdornment}
</div>
),
]);
endAdornment && (
<div key="end-adornment" className="h-5 shrink-0">
{endAdornment}
</div>
),
]
);
};

const baseClasses = [
Expand Down
1 change: 1 addition & 0 deletions packages/ui/src/IconButton/IconButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ const IconButton: React.FC<IconButtonProps> = ({
...props
}) => (
<button
type="button"
{...props}
title={alt}
className={[
Expand Down

0 comments on commit a4b8992

Please sign in to comment.