From dec57f1a9a0e32ad5e7dca306b99726ca13ddaf3 Mon Sep 17 00:00:00 2001 From: Jason Zimdars Date: Mon, 30 Jun 2025 17:30:34 -0500 Subject: [PATCH] Perform conversion on the client side --- app/javascript/controllers/filter_controller.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/javascript/controllers/filter_controller.js b/app/javascript/controllers/filter_controller.js index a7640d985..f4eadad02 100644 --- a/app/javascript/controllers/filter_controller.js +++ b/app/javascript/controllers/filter_controller.js @@ -10,7 +10,7 @@ export default class extends Controller { filter() { this.itemTargets.forEach(item => { - if (item.dataset.filterTextValue.toLowerCase().includes(this.inputTarget.value.toLowerCase())) { + if (this.#convertDiacritics(item.innerText).toLowerCase().includes(this.inputTarget.value.toLowerCase())) { item.removeAttribute("hidden") } else { item.toggleAttribute("hidden", true) @@ -19,4 +19,8 @@ export default class extends Controller { this.dispatch("changed") } + + #convertDiacritics(text) { + return text.normalize("NFD").replace(/[\u0300-\u036f]/g, "") + } }