Skip to content

Open source website builder and Webflow alternative. Webstudio is an advanced visual builder that connects to any headless CMS, supports all CSS properties, and can be hosted anywhere, including with us.

refactor: avoid rendering button inside button (#4968)

Bogdan Chadkinfbe9eed7ca62
diff --git a/apps/builder/app/builder/features/style-panel/shared/color-picker.tsx b/apps/builder/app/builder/features/style-panel/shared/color-picker.tsx
index a9638b989c..41c628a1a0 100644
--- a/apps/builder/app/builder/features/style-panel/shared/color-picker.tsx
+++ b/apps/builder/app/builder/features/style-panel/shared/color-picker.tsx
@@ -216,6 +216,7 @@ export const ColorPopover = ({
<ColorThumb
color={styleValueToRgbaColor(value)}
css={{ margin: theme.spacing[2] }}
+ interactive={true}
tabIndex={-1}
/>
</PopoverTrigger>
diff --git a/apps/builder/app/builder/features/style-panel/shared/color-thumb.tsx b/apps/builder/app/builder/features/style-panel/shared/color-thumb.tsx
index a62866abcf..15a6d605a0 100644
--- a/apps/builder/app/builder/features/style-panel/shared/color-thumb.tsx
+++ b/apps/builder/app/builder/features/style-panel/shared/color-thumb.tsx
@@ -58,13 +58,14 @@ const thumbStyle = css({
},
});
-type Props = Omit<ComponentProps<"button">, "color"> & {
+type Props = Omit<ComponentProps<"button" | "span">, "color"> & {
+ interactive?: boolean;
color?: RgbaColor;
css?: CSS;
};
export const ColorThumb = forwardRef<ElementRef<"button">, Props>(
- ({ color = transparentColor, css, ...rest }, ref) => {
+ ({ interactive, color = transparentColor, css, ...rest }, ref) => {
const background =
color === undefined || color.a < 1
? // Chessboard pattern 5x5
@@ -72,8 +73,10 @@ export const ColorThumb = forwardRef<ElementRef<"button">, Props>(
: colord(color).toRgbString();
const borderColor = calcBorderColor(color);
+ const Component = interactive ? "button" : "span";
+
return (
- <button
+ <Component
{...rest}
ref={ref}
style={{