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 select options case (#721)

Ivan Starkova9eb17fb5dc8
diff --git a/apps/designer/app/designer/features/style-panel/controls/select/select-control.tsx b/apps/designer/app/designer/features/style-panel/controls/select/select-control.tsx
index e47d2a9e53..80b69357f0 100644
--- a/apps/designer/app/designer/features/style-panel/controls/select/select-control.tsx
+++ b/apps/designer/app/designer/features/style-panel/controls/select/select-control.tsx
@@ -1,6 +1,8 @@
import { toValue } from "@webstudio-is/css-engine";
import { Select } from "@webstudio-is/design-system";
import { styleConfigByName } from "../../shared/configs";
+import { toPascalCase } from "../../shared/keyword-utils";
+import { parseCssValue } from "../../shared/parse-css-value";
import type { ControlProps } from "../../style-sections";
export const SelectControl = ({
@@ -11,7 +13,6 @@ export const SelectControl = ({
}: ControlProps) => {
const { items: defaultItems } = styleConfigByName[property];
const value = currentStyle[property]?.value;
-
const setValue = setProperty(property);
return (
@@ -19,9 +20,15 @@ export const SelectControl = ({
// show empty field instead of radix placeholder
// like css value input does
placeholder=""
- options={(items ?? defaultItems).map(({ label }) => label)}
+ options={(items ?? defaultItems).map(({ name }) => name)}
+ getLabel={(name) => {
+ return toPascalCase(name);
+ }}
value={toValue(value)}
- onChange={setValue}
+ onChange={(name) => {
+ const value = parseCssValue(property, name);
+ setValue(value);
+ }}
/>
);
};
diff --git a/apps/designer/app/designer/features/style-panel/shared/css-value-input/css-value-input.tsx b/apps/designer/app/designer/features/style-panel/shared/css-value-input/css-value-input.tsx
index 66e330ba42..41bad17d6e 100644
--- a/apps/designer/app/designer/features/style-panel/shared/css-value-input/css-value-input.tsx
+++ b/apps/designer/app/designer/features/style-panel/shared/css-value-input/css-value-input.tsx
@@ -33,7 +33,7 @@ import { parseIntermediateOrInvalidValue } from "./parse-intermediate-or-invalid
import { toValue } from "@webstudio-is/css-engine";
import { useDebouncedCallback } from "use-debounce";
import type { StyleSource } from "../style-info";
-import { toPascalCase } from "./keyword-utils";
+import { toPascalCase } from "../keyword-utils";
// We increment by 10 when shift is pressed, by 0.1 when alt/option is pressed and by 1 by default.
const calcNumberChange = (
diff --git a/apps/designer/app/designer/features/style-panel/shared/css-value-input/keyword-utils.test.ts b/apps/designer/app/designer/features/style-panel/shared/css-value-input/keyword-utils.test.ts
index bbe55b2c4d..945bd2e4af 100644
--- a/apps/designer/app/designer/features/style-panel/shared/css-value-input/keyword-utils.test.ts
+++ b/apps/designer/app/designer/features/style-panel/shared/css-value-input/keyword-utils.test.ts
@@ -1,5 +1,5 @@
import { describe, test, expect } from "@jest/globals";
-import { toKebabCase } from "./keyword-utils";
+import { toKebabCase } from "../keyword-utils";
describe("toKebabCase", () => {
test("PascalCase", () => {
diff --git a/apps/designer/app/designer/features/style-panel/shared/css-value-input/parse-intermediate-or-invalid-value.ts b/apps/designer/app/designer/features/style-panel/shared/css-value-input/parse-intermediate-or-invalid-value.ts
index 4920c9bc76..14235b36f1 100644
--- a/apps/designer/app/designer/features/style-panel/shared/css-value-input/parse-intermediate-or-invalid-value.ts
+++ b/apps/designer/app/designer/features/style-panel/shared/css-value-input/parse-intermediate-or-invalid-value.ts
@@ -7,7 +7,7 @@ import type { IntermediateStyleValue } from "./css-value-input";
import { parseCssValue } from "../parse-css-value";
import { evaluateMath } from "./evaluate-math";
import { units } from "@webstudio-is/css-data";
-import { toKebabCase } from "./keyword-utils";
+import { toKebabCase } from "../keyword-utils";
export const parseIntermediateOrInvalidValue = (
property: StyleProperty,
diff --git a/apps/designer/app/designer/features/style-panel/shared/css-value-input/keyword-utils.ts b/apps/designer/app/designer/features/style-panel/shared/keyword-utils.ts
similarity index 100%
rename from apps/designer/app/designer/features/style-panel/shared/css-value-input/keyword-utils.ts
rename to apps/designer/app/designer/features/style-panel/shared/keyword-utils.ts