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.

Merge branch 'ds-textfield' into feature-style-panel-text-control-merge

Sultand36783a2674f
diff --cc apps/designer/app/designer/features/style-panel/controls/color/color-control.tsx
index 0dae39cd15,e5674aba13..1305d95a2d
--- a/apps/designer/app/designer/features/style-panel/controls/color/color-control.tsx
+++ b/apps/designer/app/designer/features/style-panel/controls/color/color-control.tsx
@@@ -9,9 -9,9 +9,8 @@@ import
PopoverContent,
PopoverPortal,
TextField,
- Tooltip,
css,
} from "@webstudio-is/design-system";
-import { PropertyName } from "../../shared/property-name";
import { getFinalValue } from "../../shared/get-final-value";
import type { ControlProps } from "../../style-sections";
import { StyleConfig } from "../../shared/configs";
diff --cc apps/designer/app/designer/features/style-panel/controls/text/text-control.tsx
index fa43a1531a,e66679689a..78d4546cb0
--- a/apps/designer/app/designer/features/style-panel/controls/text/text-control.tsx
+++ b/apps/designer/app/designer/features/style-panel/controls/text/text-control.tsx
@@@ -1,10 -1,11 +1,9 @@@
-import { ChangeEvent, FocusEvent, KeyboardEvent, useRef } from "react";
+import { FocusEvent, PointerEvent, useCallback } from "react";
import {
- Box,
Text,
- Grid,
IconButton,
TextField,
- Tooltip,
- IconButtonWithMenu,
+ Combobox,
numericScrubControl,
} from "@webstudio-is/design-system";
import { getFinalValue } from "../../shared/get-final-value";
diff --cc packages/design-system/src/components/combobox.tsx
index 88750a3d0a,2e0dc1c1f3..a2fb903fbb
--- a/packages/design-system/src/components/combobox.tsx
+++ b/packages/design-system/src/components/combobox.tsx
@@@ -135,12 -113,12 +131,13 @@@ export const ComboboxPopperContent = Po
type ComboboxProps<Item> = {
name: string;
label?: string;
- items: Array<Item>;
+ placeholder?: string;
+ items: ReadonlyArray<Item>;
value?: Item;
+ onItemSelect?: (value?: Item) => void;
+ selected?: Item;
- onItemSelect?: (value: Item) => void;
onItemHighlight?: (value?: Item) => void;
- itemToString?: (item: Item | null) => string;
+ itemToString?: (item?: Item | null) => string;
renderTextField?: (
props: ComponentProps<typeof ComboboxTextField>
) => JSX.Element;
@@@ -153,12 -131,10 +150,11 @@@
export const Combobox = <Item extends BaseItem>({
items,
value,
+ selected = value,
name,
+ placeholder,
itemToString = (item) =>
- typeof item === "object" && item !== null && "label" in item
- ? item.label
- : item ?? "",
+ item != null && "label" in item ? item.label : item ?? "",
onItemSelect,
onItemHighlight,
renderTextField = (props) => <ComboboxTextField {...props} />,
@@@ -176,24 -185,22 +205,21 @@@
getComboboxProps,
highlightedIndex,
getItemProps,
- selectedItem,
} = useCombobox({
+ items: foundItems as Item[],
+ selectedItem: value ?? null, // Avoid downshift warning about switching controlled mode
+ stateReducer,
+ itemToString,
onInputValueChange({ inputValue }) {
- if (inputValue) {
- const options =
- typeof items[0] === "object" && "label" in items[0]
- ? { keys: ["label"] }
- : undefined;
- const foundItems = matchSorter(items, inputValue, options);
- setFoundItems(foundItems);
- }
+ const options =
+ typeof items[0] === "object" && "label" in items[0]
+ ? { keys: ["label"] }
+ : undefined;
+ const foundItems = matchSorter(items, inputValue ?? "", options);
+ setFoundItems(foundItems);
},
- items: foundItems,
- selectedItem: value,
- itemToString,
onSelectedItemChange({ selectedItem }) {
- if (selectedItem) {
- onItemSelect?.(selectedItem);
- }
+ onItemSelect?.(selectedItem ?? undefined);
},
onHighlightedIndexChange({ highlightedIndex }) {
if (highlightedIndex !== undefined) {