mirror of
https://github.com/stackblitz-labs/bolt.diy
synced 2025-03-09 21:50:36 +00:00
Enhance accessibility for ModelSelector dropdown
Added keyboard support for toggling the dropdown using Enter or Space keys, improving accessibility. Also set appropriate focus properties by adding tabindex to the combobox element.
This commit is contained in:
parent
f94be5b383
commit
2056625cbd
@ -186,10 +186,17 @@ export const ModelSelector = ({
|
||||
isModelDropdownOpen ? 'ring-2 ring-bolt-elements-focus' : undefined,
|
||||
)}
|
||||
onClick={() => setIsModelDropdownOpen(!isModelDropdownOpen)}
|
||||
onKeyDown={(e) => {
|
||||
if (e.key === 'Enter' || e.key === ' ') {
|
||||
e.preventDefault();
|
||||
setIsModelDropdownOpen(!isModelDropdownOpen);
|
||||
}
|
||||
}}
|
||||
role="combobox"
|
||||
aria-expanded={isModelDropdownOpen}
|
||||
aria-controls="model-listbox"
|
||||
aria-haspopup="listbox"
|
||||
tabIndex={0}
|
||||
>
|
||||
<div className="flex items-center justify-between">
|
||||
<div className="truncate">{modelList.find((m) => m.name === model)?.label || 'Select model'}</div>
|
||||
|
Loading…
Reference in New Issue
Block a user