feat(dashboard): scroll selected autocomplete item into view
Closes bd-4lc. When navigating with arrow keys, the selected item now
scrolls into view using scrollIntoView({ block: 'nearest' }) to prevent
jarring scrolls when item is already visible.
This commit is contained in:
File diff suppressed because one or more lines are too long
@@ -89,6 +89,17 @@ export function SimpleInput({ sessionId, status, onRespond, autocompleteConfig =
|
||||
return () => document.removeEventListener('mousedown', handleClickOutside);
|
||||
}, [showAutocomplete]);
|
||||
|
||||
// Scroll selected item into view when navigating with arrow keys
|
||||
useEffect(() => {
|
||||
if (showAutocomplete && autocompleteRef.current) {
|
||||
const container = autocompleteRef.current;
|
||||
const selectedEl = container.children[selectedIndex];
|
||||
if (selectedEl) {
|
||||
selectedEl.scrollIntoView({ block: 'nearest' });
|
||||
}
|
||||
}
|
||||
}, [selectedIndex, showAutocomplete]);
|
||||
|
||||
// Insert a selected skill into the text
|
||||
const insertSkill = useCallback((skill) => {
|
||||
if (!triggerInfo || !autocompleteConfig) return;
|
||||
|
||||
Reference in New Issue
Block a user