From ec4f707ea22840eff1726f46776d3f892c27bece Mon Sep 17 00:00:00 2001 From: mam15mon Date: Tue, 21 Jul 2026 09:44:22 +0800 Subject: [PATCH] Keep plugin palette selections visible --- components/QuickSwitcher.tsx | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/components/QuickSwitcher.tsx b/components/QuickSwitcher.tsx index 2149ee921..e5e8a8280 100644 --- a/components/QuickSwitcher.tsx +++ b/components/QuickSwitcher.tsx @@ -103,7 +103,7 @@ const HostItem = memo(({ }: { host: Host; isSelected: boolean; - selectedItemRef?: React.Ref; + selectedItemRef?: React.RefCallback; onSelect: (host: Host) => void; onMouseEnter: () => void; }) => ( @@ -195,7 +195,10 @@ const QuickSwitcherInner: React.FC = ({ const [selectedIndex, setSelectedIndex] = useState(0); const inputRef = useRef(null); const containerRef = useRef(null); - const selectedItemRef = useRef(null); + const selectedItemRef = useRef(null); + const setSelectedItemRef = useCallback((element: HTMLElement | null) => { + selectedItemRef.current = element; + }, []); // Reset state when opening useEffect(() => { @@ -461,7 +464,7 @@ const QuickSwitcherInner: React.FC = ({ key={host.id} host={host} isSelected={getItemIndex("host", host.id) === selectedIndex} - selectedItemRef={getItemIndex("host", host.id) === selectedIndex ? selectedItemRef : undefined} + selectedItemRef={getItemIndex("host", host.id) === selectedIndex ? setSelectedItemRef : undefined} onSelect={onSelect} onMouseEnter={() => setSelectedIndex(getItemIndex("host", host.id))} /> @@ -492,7 +495,7 @@ const QuickSwitcherInner: React.FC = ({ return (
{ @@ -517,7 +520,7 @@ const QuickSwitcherInner: React.FC = ({ return (
{ @@ -544,7 +547,7 @@ const QuickSwitcherInner: React.FC = ({ return (
{ @@ -579,7 +582,7 @@ const QuickSwitcherInner: React.FC = ({ return (
= ({
= ({