bugfix: remove selected class from other options

This commit is contained in:
Starbeamrainbowlabs 2022-02-02 01:57:22 +00:00
parent 277b500f21
commit d6c7417958
Signed by: sbrl
GPG Key ID: 1BE5172E637709C2
1 changed files with 6 additions and 1 deletions

View File

@ -32,9 +32,14 @@ function handle_mutation_word_keyup(event) {
const el_mutations = document.querySelector("#mutations");
const el_step = event.target.closest(".mutation-step");
const el_word = event.target.closest(".mutation-option");
const els_word = el_step.querySelectorAll(".mutation-option");
// 2: Update UI - Change classes, Remove all subsequent mutation steps
for(let i = 0; i < els_word.length; i++)
els_word[i].classList.remove("selected");
// 2: Update UI - Add classes, Remove all subsequent mutation steps
el_word.classList.add("selected");
while(el_step.nextElementSibling !== null)
el_step.parentNode.removeChild(el_step.nextElementSibling);