Skip to content

Commit 5913802

Browse files
committed
Fix accessibility issues in SelectInputSettingsPanel radio buttons
- Replace non-semantic div with role='radio' with semantic <label> elements - Remove manual role, tabIndex, aria-checked attributes from wrapper - Remove manual keyboard handlers (Enter/Space) - native radio behavior - Associate labels with radio inputs for proper click handling - Remove stopPropagation calls - no longer needed with semantic structure - Radio inputs now work natively for screen readers and keyboard users - Maintains existing visual styling via .radio-option CSS class
1 parent c090db7 commit 5913802

File tree

1 file changed

+6
-41
lines changed

1 file changed

+6
-41
lines changed

src/webviews/webview-side/selectInputSettings/SelectInputSettingsPanel.tsx

Lines changed: 6 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -133,19 +133,7 @@ export const SelectInputSettingsPanel: React.FC<ISelectInputSettingsPanelProps>
133133
<h2>{getLocString('valueSourceTitle', 'Value')}</h2>
134134

135135
<div className="value-source-section">
136-
<div
137-
className={`radio-option ${settings.selectType === 'from-options' ? 'selected' : ''}`}
138-
onClick={() => handleSelectTypeChange('from-options')}
139-
onKeyDown={(e) => {
140-
if (e.key === 'Enter' || e.key === ' ') {
141-
e.preventDefault();
142-
handleSelectTypeChange('from-options');
143-
}
144-
}}
145-
role="radio"
146-
tabIndex={0}
147-
aria-checked={settings.selectType === 'from-options'}
148-
>
136+
<label className={`radio-option ${settings.selectType === 'from-options' ? 'selected' : ''}`}>
149137
<input
150138
type="radio"
151139
id="fromOptions"
@@ -166,10 +154,7 @@ export const SelectInputSettingsPanel: React.FC<ISelectInputSettingsPanelProps>
166154
{option}
167155
<button
168156
type="button"
169-
onClick={(e) => {
170-
e.stopPropagation();
171-
handleRemoveOption(index);
172-
}}
157+
onClick={() => handleRemoveOption(index)}
173158
aria-label="Remove option"
174159
>
175160
×
@@ -189,36 +174,17 @@ export const SelectInputSettingsPanel: React.FC<ISelectInputSettingsPanelProps>
189174
}
190175
}}
191176
placeholder={getLocString('addOptionPlaceholder', 'Add option...')}
192-
onClick={(e) => e.stopPropagation()}
193177
/>
194-
<button
195-
type="button"
196-
onClick={(e) => {
197-
e.stopPropagation();
198-
handleAddOption();
199-
}}
200-
>
178+
<button type="button" onClick={handleAddOption}>
201179
{getLocString('addButton', 'Add')}
202180
</button>
203181
</div>
204182
</div>
205183
)}
206184
</div>
207-
</div>
185+
</label>
208186

209-
<div
210-
className={`radio-option ${settings.selectType === 'from-variable' ? 'selected' : ''}`}
211-
onClick={() => handleSelectTypeChange('from-variable')}
212-
onKeyDown={(e) => {
213-
if (e.key === 'Enter' || e.key === ' ') {
214-
e.preventDefault();
215-
handleSelectTypeChange('from-variable');
216-
}
217-
}}
218-
role="radio"
219-
tabIndex={0}
220-
aria-checked={settings.selectType === 'from-variable'}
221-
>
187+
<label className={`radio-option ${settings.selectType === 'from-variable' ? 'selected' : ''}`}>
222188
<input
223189
type="radio"
224190
id="fromVariable"
@@ -242,11 +208,10 @@ export const SelectInputSettingsPanel: React.FC<ISelectInputSettingsPanelProps>
242208
value={settings.selectedVariable}
243209
onChange={handleVariableChange}
244210
placeholder={getLocString('variablePlaceholder', 'Variable name...')}
245-
onClick={(e) => e.stopPropagation()}
246211
/>
247212
)}
248213
</div>
249-
</div>
214+
</label>
250215
</div>
251216

252217
<div className="actions">

0 commit comments

Comments
 (0)