Skip to content

Commit bc41f8b

Browse files
Show full country list in registration combobox when empty (#201)
The empty-query branch capped the list at 20 countries, so a user focusing the field saw only the first 20 with no way to reach the rest without typing. Return the full list on empty query (the panel already has max-height + overflow-y:auto to scroll), and scroll the active option into view during keyboard navigation.
1 parent 19b82f2 commit bc41f8b

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

courses/static/country_combobox.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
function matchingCountries(query) {
1919
const normalizedQuery = normalize(query);
2020
if (!normalizedQuery) {
21-
return countries.slice(0, 20);
21+
return countries.slice();
2222
}
2323

2424
const startsWith = [];
@@ -90,7 +90,11 @@
9090

9191
activeIndex = (nextIndex + visibleCountries.length) % visibleCountries.length;
9292
panel.querySelectorAll(".country-combobox-option").forEach((option, index) => {
93-
option.setAttribute("aria-selected", index === activeIndex ? "true" : "false");
93+
const isActive = index === activeIndex;
94+
option.setAttribute("aria-selected", isActive ? "true" : "false");
95+
if (isActive) {
96+
option.scrollIntoView({ block: "nearest" });
97+
}
9498
});
9599
input.setAttribute("aria-activedescendant", "country-option-" + activeIndex);
96100
}

0 commit comments

Comments
 (0)