Skip to content

Commit 84f4404

Browse files
committed
add accessible labels to select input settings
1 parent f478300 commit 84f4404

File tree

2 files changed

+31
-7
lines changed

2 files changed

+31
-7
lines changed

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

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -179,8 +179,12 @@ export const SelectInputSettingsPanel: React.FC<ISelectInputSettingsPanelProps>
179179
))}
180180

181181
<div className="add-option-form">
182+
<label htmlFor="addOptionInput" className="visually-hidden">
183+
Option name
184+
</label>
182185
<input
183186
type="text"
187+
id="addOptionInput"
184188
value={newOption}
185189
onChange={(e) => setNewOption(e.target.value)}
186190
onKeyDown={(e) => {
@@ -190,6 +194,7 @@ export const SelectInputSettingsPanel: React.FC<ISelectInputSettingsPanelProps>
190194
}
191195
}}
192196
placeholder={getLocString('addOptionPlaceholder', 'Add option...')}
197+
aria-label="Option name"
193198
/>
194199
<button type="button" onClick={handleAddOption}>
195200
{getLocString('addButton', 'Add')}
@@ -218,13 +223,20 @@ export const SelectInputSettingsPanel: React.FC<ISelectInputSettingsPanelProps>
218223
</div>
219224

220225
{settings.selectType === 'from-variable' && (
221-
<input
222-
type="text"
223-
className="variable-input"
224-
value={settings.selectedVariable}
225-
onChange={handleVariableChange}
226-
placeholder={getLocString('variablePlaceholder', 'Variable name...')}
227-
/>
226+
<>
227+
<label htmlFor="variableNameInput" className="visually-hidden">
228+
Variable name
229+
</label>
230+
<input
231+
type="text"
232+
id="variableNameInput"
233+
className="variable-input"
234+
value={settings.selectedVariable}
235+
onChange={handleVariableChange}
236+
placeholder={getLocString('variablePlaceholder', 'Variable name...')}
237+
aria-label="Variable name"
238+
/>
239+
</>
228240
)}
229241
</div>
230242
</label>

src/webviews/webview-side/selectInputSettings/selectInputSettings.css

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,18 @@
44
margin: 0 auto;
55
}
66

7+
.visually-hidden {
8+
position: absolute;
9+
width: 1px;
10+
height: 1px;
11+
padding: 0;
12+
margin: -1px;
13+
overflow: hidden;
14+
clip: rect(0, 0, 0, 0);
15+
white-space: nowrap;
16+
border-width: 0;
17+
}
18+
719
.select-input-settings-panel h1 {
820
font-size: 24px;
921
margin-bottom: 20px;

0 commit comments

Comments
 (0)