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.

fix: fix font family control when value is inherit (#4161)

Oleg Isonena0bce7284ce3
diff --git a/apps/builder/app/builder/features/style-panel/controls/font-family/font-family-control.tsx b/apps/builder/app/builder/features/style-panel/controls/font-family/font-family-control.tsx
index 7f2a3c7864..7cc8a31d6a 100644
--- a/apps/builder/app/builder/features/style-panel/controls/font-family/font-family-control.tsx
+++ b/apps/builder/app/builder/features/style-panel/controls/font-family/font-family-control.tsx
@@ -61,10 +61,6 @@ export const FontFamilyControl = () => {
return toValue(value, (value) => value).replace(/"/g, "");
}, [value]);
- if (value.type !== "fontFamily") {
- return;
- }
-
return (
<Flex>
<Combobox<Item>
@@ -73,7 +69,7 @@ export const FontFamilyControl = () => {
title="Fonts"
content={
<FontsManager
- value={value}
+ value={value.type === "fontFamily" ? value : undefined}
onChange={(newValue = itemValue) => {
setValue({ type: "fontFamily", value: [newValue] });
}}
diff --git a/apps/builder/app/builder/shared/fonts-manager/fonts-manager.tsx b/apps/builder/app/builder/shared/fonts-manager/fonts-manager.tsx
index 9338ca5fce..66a941e72f 100644
--- a/apps/builder/app/builder/shared/fonts-manager/fonts-manager.tsx
+++ b/apps/builder/app/builder/shared/fonts-manager/fonts-manager.tsx
@@ -63,7 +63,7 @@ const useLogic = ({ onChange, value }: FontsManagerProps) => {
);
const currentIndex = useMemo(() => {
- return groupedItems.findIndex((item) => item.label === value.value[0]);
+ return groupedItems.findIndex((item) => item.label === value?.value[0]);
}, [groupedItems, value]);
const handleChangeCurrent = (nextCurrentIndex: number) => {
@@ -104,7 +104,7 @@ const useLogic = ({ onChange, value }: FontsManagerProps) => {
};
type FontsManagerProps = {
- value: FontFamilyValue;
+ value?: FontFamilyValue;
onChange: (value?: string) => void;
};