From ecd47f67c3530587ae549611c48c2f945d1fcd08 Mon Sep 17 00:00:00 2001 From: Jonathan Summers-Muir Date: Tue, 13 Jun 2023 19:39:26 +0800 Subject: [PATCH] Update Button.tsx --- packages/ui/src/components/Button/Button.tsx | 23 +++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/packages/ui/src/components/Button/Button.tsx b/packages/ui/src/components/Button/Button.tsx index bb4d0eaa138..5fe78850166 100644 --- a/packages/ui/src/components/Button/Button.tsx +++ b/packages/ui/src/components/Button/Button.tsx @@ -148,15 +148,28 @@ export interface ButtonProps } const Button = React.forwardRef( - ({ asChild = false, size = 'tiny', type = 'primary', children, ...props }, ref) => { + ( + { + asChild = false, + size = 'tiny', + type = 'primary', + children, + loading, + block, + icon, + iconRight, + iconLeft, + ...props + }, + ref + ) => { const Comp = asChild ? Slot : 'button' - - const { className, disabled, loading, icon, iconLeft, iconRight, block } = props - + const { className, disabled } = props const showIcon = loading || icon - // decrecating 'showIcon' for rightIcon const _iconLeft: React.ReactNode = icon ?? iconLeft + // if loading, button is disabled + props.disabled = loading ? true : props.disabled return (