From 2678f8c099ca5c355e03aabc2e9a86eefab75ce0 Mon Sep 17 00:00:00 2001 From: Jason Zimdars Date: Mon, 30 Jun 2025 13:53:50 -0500 Subject: [PATCH] Convert diacritics to approximations before filtering - Introduces a helper method for setting the filterable value - Updates `filter_controller.js` to use `data-filter-text-value` attribute populated with converted content. This was previous `data-value` in the earlier implementation but ignored in the current on. - Also uses the same helper to make @mentions diacritic insensitive --- app/assets/stylesheets/popup.css | 1 + app/helpers/application_helper.rb | 4 ++++ app/javascript/controllers/filter_controller.js | 2 +- app/views/accounts/_user.html.erb | 2 +- app/views/cards/assignments/new.html.erb | 2 +- app/views/cards/display/perma/_collection.html.erb | 2 +- app/views/cards/index/_collections_filter.html.erb | 6 +++--- app/views/cards/show/_collections.html.erb | 6 +++--- app/views/cards/taggings/new.html.erb | 2 +- app/views/collections/_access_toggle.erb | 2 +- .../events/filter/_all_collections_option.html.erb | 4 ++-- app/views/events/filter/_collection_option.html.erb | 2 +- app/views/events/filter/_custom_collections.html.erb | 4 ++-- app/views/events/filter/_header.html.erb | 12 ++++++------ app/views/events/filter/_tag.html.erb | 2 +- app/views/events/filter/_user.html.erb | 2 +- app/views/filters/_assignees.html.erb | 4 ++-- app/views/filters/_creators.html.erb | 2 +- app/views/filters/_tags.html.erb | 2 +- app/views/prompts/collections/users/_user.html.erb | 2 +- 20 files changed, 35 insertions(+), 30 deletions(-) diff --git a/app/assets/stylesheets/popup.css b/app/assets/stylesheets/popup.css index addd87f2d..57c940cb1 100644 --- a/app/assets/stylesheets/popup.css +++ b/app/assets/stylesheets/popup.css @@ -38,6 +38,7 @@ border-block-start: 1px solid var(--color-ink-lighter); font-size: var(--text-small); inset: auto 0 0; + margin-block-start: var(--block-space-half); margin-inline: calc(var(--block-space) * -1); padding: var(--block-space-half) var(--inline-space) var(--block-space); position: sticky; diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 52783033c..86b08db45 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -6,4 +6,8 @@ module ApplicationHelper def icon_tag(name, **options) tag.span class: class_names("icon icon--#{name}", options.delete(:class)), "aria-hidden": true, **options end + + def filterable_name(text) + I18n.transliterate(text.to_s).downcase + end end diff --git a/app/javascript/controllers/filter_controller.js b/app/javascript/controllers/filter_controller.js index 98c6843bc..a7640d985 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.innerText.toLowerCase().includes(this.inputTarget.value.toLowerCase())) { + if (item.dataset.filterTextValue.toLowerCase().includes(this.inputTarget.value.toLowerCase())) { item.removeAttribute("hidden") } else { item.toggleAttribute("hidden", true) diff --git a/app/views/accounts/_user.html.erb b/app/views/accounts/_user.html.erb index 123b2553e..b4dd50fda 100644 --- a/app/views/accounts/_user.html.erb +++ b/app/views/accounts/_user.html.erb @@ -1,4 +1,4 @@ -
  • +
  • <%= avatar_tag user, class: "flex-item-no-shrink" %> diff --git a/app/views/cards/assignments/new.html.erb b/app/views/cards/assignments/new.html.erb index 9ab019cac..b1d8728b9 100644 --- a/app/views/cards/assignments/new.html.erb +++ b/app/views/cards/assignments/new.html.erb @@ -14,7 +14,7 @@