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.
TypeScript accessibilityalternativecloudflarecloudflare-workersdesignfreefrontendopen-sourceradix-uireactremixweb-developmentwebflowwebsite-builderwebsite-developmentwebsiteswebstudio
focus input after closing unit selector
Oleg Isonen14b24dbf2d39
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.tsxindex 8b9c02fd5a..78b21b1fc7 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@@ -220,6 +220,12 @@ export const CssValueInput = ({const [isUnitsOpen, unitSelectElement] = useUnitSelect({value: value.type === "unit" ? value : undefined,onChange: onChangeComplete,+ onCloseAutoFocus(event) {+ // We don't want to focus the unit trigger when closing the select (no matter if unit was selected, clicked outside or esc was pressed)+ event.preventDefault();+ // Instead we want to focus the input+ inputRef.current?.focus();+ },});const inputRef = useScrub({diff --git a/apps/designer/app/designer/features/style-panel/shared/css-value-input/unit-select.tsx b/apps/designer/app/designer/features/style-panel/shared/css-value-input/unit-select.tsxindex d042d231eb..aa8691fde8 100644--- a/apps/designer/app/designer/features/style-panel/shared/css-value-input/unit-select.tsx+++ b/apps/designer/app/designer/features/style-panel/shared/css-value-input/unit-select.tsx@@ -24,6 +24,7 @@ type UseUnitSelectType = {value?: UnitValue;onChange: (value: StyleValue) => void;units?: Array<Unit>;+ onCloseAutoFocus: (event: Event) => void;};export const useUnitSelect = ({@@ -38,6 +39,7 @@ export const useUnitSelect = ({[units]);if (value === undefined) return [isOpen, null];+const element = (<Select{...props}@@ -55,10 +57,6 @@ export const useUnitSelect = ({unit,});}}- onCloseAutoFocus={(event) => {- // We don't want to focus the unit trigger when closing the select (no matter if unit was selected, clicked outside or esc was pressed)- event.preventDefault();- }}/>);