mirror of
https://github.com/simstudioai/sim.git
synced 2026-09-24 15:45:35 +08:00
fix(ui): support Tab key to select items in tag, env-var, and resource dropdowns (#4096)
* fix(ui): support Tab key to select items in tag, env-var, and resource dropdowns * fix(ui): support Tab key to select items in tag, env-var, and resource dropdowns * fix(ui): guard Tab selection against Shift+Tab and undefined index
This commit is contained in:
+2
-2
@@ -167,9 +167,9 @@ export function AddResourceDropdown({
|
||||
} else if (e.key === 'ArrowUp') {
|
||||
e.preventDefault()
|
||||
setActiveIndex((prev) => Math.max(prev - 1, 0))
|
||||
} else if (e.key === 'Enter') {
|
||||
e.preventDefault()
|
||||
} else if (e.key === 'Enter' || (e.key === 'Tab' && !e.shiftKey)) {
|
||||
if (filtered.length > 0 && filtered[activeIndex]) {
|
||||
e.preventDefault()
|
||||
const { type, item } = filtered[activeIndex]
|
||||
select({ type, id: item.id, title: item.name }, item.isOpen)
|
||||
}
|
||||
|
||||
+7
-3
@@ -242,9 +242,13 @@ export const EnvVarDropdown: React.FC<EnvVarDropdownProps> = ({
|
||||
})
|
||||
break
|
||||
case 'Enter':
|
||||
e.preventDefault()
|
||||
e.stopPropagation()
|
||||
handleEnvVarSelect(filteredEnvVars[selectedIndex])
|
||||
case 'Tab':
|
||||
if (e.key === 'Tab' && e.shiftKey) break
|
||||
if (filteredEnvVars[selectedIndex]) {
|
||||
e.preventDefault()
|
||||
e.stopPropagation()
|
||||
handleEnvVarSelect(filteredEnvVars[selectedIndex])
|
||||
}
|
||||
break
|
||||
case 'Escape':
|
||||
e.preventDefault()
|
||||
|
||||
+4
-2
@@ -279,9 +279,11 @@ export const KeyboardNavigationHandler: React.FC<KeyboardNavigationHandlerProps>
|
||||
}
|
||||
break
|
||||
case 'Enter':
|
||||
e.preventDefault()
|
||||
e.stopPropagation()
|
||||
case 'Tab':
|
||||
if (e.key === 'Tab' && e.shiftKey) break
|
||||
if (selected && selectedIndex >= 0 && selectedIndex < flatTagList.length) {
|
||||
e.preventDefault()
|
||||
e.stopPropagation()
|
||||
handleTagSelect(selected.tag, selected.group)
|
||||
}
|
||||
break
|
||||
|
||||
Reference in New Issue
Block a user