diff --git a/src/renderer/src/components/settings/SettingsFormControls.tsx b/src/renderer/src/components/settings/SettingsFormControls.tsx index bb4212c3a..7c4ec8f10 100644 --- a/src/renderer/src/components/settings/SettingsFormControls.tsx +++ b/src/renderer/src/components/settings/SettingsFormControls.tsx @@ -456,7 +456,6 @@ export function FontAutocomplete({ const inputRef = useRef(null) const rootRef = useRef(null) const previewFontFamilyRef = useRef(onPreviewFontFamily) - const optionRefs = useRef(new Map()) const listboxId = useId() previewFontFamilyRef.current = onPreviewFontFamily @@ -523,19 +522,6 @@ export function FontAutocomplete({ } } - useEffect(() => { - if (!open || highlightedIndex < 0) { - return - } - - const highlightedFont = filteredSuggestions[highlightedIndex] - if (!highlightedFont) { - return - } - - optionRefs.current.get(highlightedFont)?.scrollIntoView({ block: 'nearest' }) - }, [filteredSuggestions, highlightedIndex, open]) - // Why: notify the consumer of the currently-highlighted font so it can // render a live preview. Closing the dropdown or moving past all options // clears the preview back to the committed value. @@ -672,11 +658,9 @@ export function FontAutocomplete({ role="option" aria-selected={index === highlightedIndex} ref={(element) => { - if (element) { - optionRefs.current.set(font, element) - return + if (element && index === highlightedIndex) { + element.scrollIntoView({ block: 'nearest' }) } - optionRefs.current.delete(font) }} onMouseDown={(e) => e.preventDefault()} onMouseEnter={() => setHighlightedIndex(index)}