Skip to content

Commit

Permalink
retour du tri des tags suppr par erreur
Browse files Browse the repository at this point in the history
  • Loading branch information
olafswan committed Sep 25, 2023
1 parent a3b820d commit 1615a25
Showing 1 changed file with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions js/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -1899,6 +1899,29 @@ class App {

// utilisation de la method optionSelection pour rendre possible la séléction des tags
this.optionSelection();

// FONCTION DE TRI DES TAGS

// ciblage des containers des search bars
const ingredientsSearch = document.querySelector("#ingredientsSearch");
const appliancesSearch = document.querySelector("#appliancesSearch");
const ustensilsSearch = document.querySelector("#ustensilsSearch");
const searchOptions = [
ingredientsSearch,
appliancesSearch,
ustensilsSearch,
];
searchOptions.forEach((option) => {
option.addEventListener("input", () => {
// console.log(
// "-- \nnew input in option search\n--",
// option,
// option.value
// );
this.optionTrimmer(option, this.normalize(option.value));
// utiliser l'option selectionnée pour trim la list
});
});
}

// METHOD DE RECHERCHE VIA LA SEARCH BAR
Expand Down Expand Up @@ -2313,6 +2336,25 @@ class App {
}
});
}

// METHOD POUR EFFECTUER LE TRI DES TAGS
optionTrimmer(option, value) {
const selectOptionsContainer = option.parentNode.parentNode.querySelector(
".select-options-container"
);

const selectOptions =
selectOptionsContainer.querySelectorAll(".select-option");

selectOptions.forEach((option) => {
option.style.display = "block";
if (!this.normalize(option.innerText).includes(value)) {
option.style.display = "none";
}
});

//parentNode
}
}

const app = new App();
Expand Down

0 comments on commit 1615a25

Please sign in to comment.