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.

unselect item when focus moves outisde of list

Oleg Isonen3501881dd1eb
diff --git a/apps/designer/app/designer/shared/fonts-manager/fonts-manager.tsx b/apps/designer/app/designer/shared/fonts-manager/fonts-manager.tsx
index ec15f10280..d3f50e591c 100644
--- a/apps/designer/app/designer/shared/fonts-manager/fonts-manager.tsx
+++ b/apps/designer/app/designer/shared/fonts-manager/fonts-manager.tsx
@@ -69,7 +69,7 @@ const filterIdsByFamily = (
const findNextIndex = (
currentIndex: number,
total: number,
- indexOrDirection: number | "next" | "previous"
+ indexOrDirection: "next" | "previous"
) => {
const nextIndex =
indexOrDirection === "next"
@@ -114,6 +114,10 @@ const useLogic = ({ onChange }: { onChange: (value: string) => void }) => {
};
const handleSelectItem = (indexOrDirection: number | "next" | "previous") => {
+ if (typeof indexOrDirection === "number") {
+ setSelectedItemIndex(indexOrDirection);
+ return;
+ }
const nextIndex = findNextIndex(
selectedItemIndex,
filteredItems.length,
@@ -197,7 +201,14 @@ export const FontsManager = ({ value, onChange }: FontsManagerProps) => {
px: "$3",
}}
>
- <List onKeyDown={handleKeyDown}>
+ <List
+ onKeyDown={handleKeyDown}
+ onBlur={(event) => {
+ if (event.currentTarget.contains(event.relatedTarget) === false) {
+ handleSelectItem(-1);
+ }
+ }}
+ >
{uploadedItems.length !== 0 && (
<ListItem state="disabled">{"Uploaded"}</ListItem>
)}