Skip to content

Open-source manufacturing ERP, MES and QMS. Quoting, MRP, inventory, shop floor, quality and lot/serial traceability on one Postgres schema, with a REST API and MCP server. Self-host or use Carbon Cloud.

fix(react): loading icon buttons rendered a clipped spinner + icon

Sidwebworks76715e3e0c4a
diff --git a/packages/react/src/Button.tsx b/packages/react/src/Button.tsx
index 7152b55a00..f7c9041390 100644
--- a/packages/react/src/Button.tsx
+++ b/packages/react/src/Button.tsx
@@ -162,7 +162,9 @@ const Button = forwardRef<HTMLButtonElement, ButtonProps>(
role={asChild ? undefined : "button"}
ref={ref}
>
- {isLoading && <Spinner className="mr-2 size-4" />}
+ {isLoading && (
+ <Spinner className={cn("size-4 flex-shrink-0", !isIcon && "mr-2")} />
+ )}
{!isLoading &&
leftIcon &&
cloneElement(leftIcon, {
@@ -170,7 +172,9 @@ const Button = forwardRef<HTMLButtonElement, ButtonProps>(
? cn("mr-2 h-4 w-4 flex-shrink-0", leftIcon.props.className)
: cn("mr-2 flex-shrink-0", leftIcon.props.className)
})}
- <Slottable>{children}</Slottable>
+ {/* An icon button's icon arrives as children — while loading, the
+ spinner must REPLACE it or both clip inside the square hit area. */}
+ {isIcon && isLoading ? null : <Slottable>{children}</Slottable>}
{rightIcon &&
cloneElement(rightIcon, {
className: !rightIcon.props?.size