Skip to content

Commit 8a29899

Browse files
committed
fix: fix font family control when value is inherit (#4161)
## Description Turns out value in controls can also be {type: 'inherit'}, not just type fontFamily ## Steps for reproduction 1. click button 2. expect xyz ## Code Review - [ ] hi @kof, I need you to do - conceptual review (architecture, feature-correctness) - detailed review (read every line) - test it on preview ## Before requesting a review - [ ] made a self-review - [ ] added inline comments where things may be not obvious (the "why", not "what") ## Before merging - [ ] tested locally and on preview environment (preview dev login: 5de6) - [ ] updated [test cases](https://github.com/webstudio-is/webstudio/blob/main/apps/builder/docs/test-cases.md) document - [ ] added tests - [ ] if any new env variables are added, added them to `.env` file
1 parent 8ea47de commit 8a29899

File tree

2 files changed

+3
-7
lines changed

2 files changed

+3
-7
lines changed

apps/builder/app/builder/features/style-panel/controls/font-family/font-family-control.tsx

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,6 @@ export const FontFamilyControl = () => {
6161
return toValue(value, (value) => value).replace(/"/g, "");
6262
}, [value]);
6363

64-
if (value.type !== "fontFamily") {
65-
return;
66-
}
67-
6864
return (
6965
<Flex>
7066
<Combobox<Item>
@@ -73,7 +69,7 @@ export const FontFamilyControl = () => {
7369
title="Fonts"
7470
content={
7571
<FontsManager
76-
value={value}
72+
value={value.type === "fontFamily" ? value : undefined}
7773
onChange={(newValue = itemValue) => {
7874
setValue({ type: "fontFamily", value: [newValue] });
7975
}}

apps/builder/app/builder/shared/fonts-manager/fonts-manager.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ const useLogic = ({ onChange, value }: FontsManagerProps) => {
6363
);
6464

6565
const currentIndex = useMemo(() => {
66-
return groupedItems.findIndex((item) => item.label === value.value[0]);
66+
return groupedItems.findIndex((item) => item.label === value?.value[0]);
6767
}, [groupedItems, value]);
6868

6969
const handleChangeCurrent = (nextCurrentIndex: number) => {
@@ -104,7 +104,7 @@ const useLogic = ({ onChange, value }: FontsManagerProps) => {
104104
};
105105

106106
type FontsManagerProps = {
107-
value: FontFamilyValue;
107+
value?: FontFamilyValue;
108108
onChange: (value?: string) => void;
109109
};
110110

0 commit comments

Comments
 (0)