mirror of
https://github.com/webstudio-is/webstudio.git
synced 2026-11-07 12:33:36 +09:00
fix currentIndex in font manager when new fonts are added
This commit is contained in:
1 parent
ac03e0b3b1
commit
63ded04e13
1 file changed
+6
-4
@@ -10,7 +10,7 @@ import {
|
||||
useAssets,
|
||||
useSearch,
|
||||
} from "~/designer/shared/assets";
|
||||
import { useMemo, useState } from "react";
|
||||
import { useEffect, useMemo, useState } from "react";
|
||||
import { useMenu } from "./item-menu";
|
||||
import { CheckIcon } from "@webstudio-is/icons";
|
||||
import {
|
||||
@@ -42,9 +42,11 @@ const useLogic = ({
|
||||
() => groupItemsByType(filteredItems),
|
||||
[filteredItems]
|
||||
);
|
||||
const [currentIndex, setCurrentIndex] = useState(() =>
|
||||
groupedItems.findIndex((item) => item.label === value)
|
||||
);
|
||||
const [currentIndex, setCurrentIndex] = useState(-1);
|
||||
|
||||
useEffect(() => {
|
||||
setCurrentIndex(groupedItems.findIndex((item) => item.label === value));
|
||||
}, [groupedItems]);
|
||||
|
||||
const handleChangeCurrent = (nextCurrentIndex: number) => {
|
||||
const item = groupedItems[nextCurrentIndex];
|
||||
|
||||
Reference in new issue
Block a user