Skip to content

Commit a894960

Browse files
ARIA activedescendant, label
1 parent de63b80 commit a894960

File tree

4 files changed

+5
-1
lines changed

4 files changed

+5
-1
lines changed

lib/clear-suggestions.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,6 @@ function clearSuggestions(state) {
66
state.selectedIndex = -1;
77
removeListElement(state);
88
state.input.removeAttribute("aria-controls");
9+
state.input.removeAttribute("aria-activedescendant");
910
state.plete.setAttribute("aria-expanded", "false");
1011
}

lib/highlight.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ function highlight(state, index) {
55
const item = state.list.querySelectorAll("plete-item")[index];
66
if (item) {
77
item.classList.add("highlight");
8+
state.input.setAttribute("aria-activedescendant", item.id);
89
}
910
}
1011
}

lib/render-item.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ function renderItem(state, value) {
88
const attrValue = valueIsString ? value : value.id;
99
const label = valueIsString ? value : value.label;
1010

11+
item.setAttribute("aria-label", `Choice: ${label}.`);
1112
item.setAttribute("value", attrValue);
1213
item.setAttribute("title", label);
1314

lib/render.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ function render(state, data) {
99
addListElement(state, select);
1010
const boundRenderItem = renderItem.bind(null, state);
1111

12-
data.map(boundRenderItem).forEach(function(item) {
12+
data.map(boundRenderItem).forEach(function(item, idx) {
13+
item.id = `plete-item-${idx}`;
1314
state.list.appendChild(item);
1415
});
1516

0 commit comments

Comments
 (0)