diff options
Diffstat (limited to 'cockpit')
| -rw-r--r-- | cockpit/js/cockpit.js | 11 |
1 files changed, 4 insertions, 7 deletions
diff --git a/cockpit/js/cockpit.js b/cockpit/js/cockpit.js index 23714ab..f701706 100644 --- a/cockpit/js/cockpit.js +++ b/cockpit/js/cockpit.js @@ -45,6 +45,7 @@ async function initStudentSelection() { const sel = document.getElementById("student-selection"); const list = document.getElementById('student-selection-list'); const noResults = document.getElementById('student-selection-noresults'); + const clearBtn = document.getElementById('student-selection-clear'); const students = await fetchStudents(); @@ -99,21 +100,17 @@ async function initStudentSelection() { } } + // Show the clear button if there is an input + clearBtn.style.display = sel.value ? "block" : "none"; + // Select the first or none if there are no items visible currentFocus = visibleItems.length ? 0 : -1; setActive(visibleItems); noResults.style.display = visibleItems.length || filter === "" ? "none" : "block"; }); - const clearBtn = document.getElementById('student-selection-clear'); - - sel.addEventListener('input', function() { - clearBtn.style.display = sel.value ? "block" : "none"; - }); - clearBtn.addEventListener('click', function() { sel.value = ""; - clearBtn.style.display = "none"; sel.dispatchEvent(new Event('keyup')); // reset list sel.focus(); }); |
