diff options
| author | Florian Fischer <florian.fischer@muhq.space> | 2026-05-28 15:49:46 +0200 |
|---|---|---|
| committer | Florian Fischer <florian.fischer@muhq.space> | 2026-05-28 15:49:46 +0200 |
| commit | b7b9f1f5799d162661386ec6f2b72bde9c3ae493 (patch) | |
| tree | 348f6527683b9a77ce141c67e159452b9811cfbd /cockpit | |
| parent | 84dfe717a64138b75396fd21b995b68330468f8f (diff) | |
| download | bycs-sol-b7b9f1f5799d162661386ec6f2b72bde9c3ae493.tar.gz bycs-sol-b7b9f1f5799d162661386ec6f2b72bde9c3ae493.zip | |
cockpit: hide clear button when a student is selected
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(); }); |
