From 61fbad218b8bb27f33d1562795b59b422ea30148 Mon Sep 17 00:00:00 2001 From: Jorge Manrubia Date: Mon, 2 Jun 2025 18:39:44 +0200 Subject: [PATCH] Make tag filters selectable/navigable too --- app/assets/stylesheets/popup.css | 4 ++++ .../controllers/navigable_list_controller.js | 7 ++++--- app/views/cards/taggings/new.html.erb | 18 +++++++++++++----- 3 files changed, 21 insertions(+), 8 deletions(-) diff --git a/app/assets/stylesheets/popup.css b/app/assets/stylesheets/popup.css index b97f243af..4dafb7603 100644 --- a/app/assets/stylesheets/popup.css +++ b/app/assets/stylesheets/popup.css @@ -81,6 +81,10 @@ } } + &[aria-selected] { + --btn-background: var(--color-selected); + } + &:has(input:checked) { --btn-background: var(--color-ink-lightest); --btn-color: var(--color-ink); diff --git a/app/javascript/controllers/navigable_list_controller.js b/app/javascript/controllers/navigable_list_controller.js index a1af5a938..a1dbd7f45 100644 --- a/app/javascript/controllers/navigable_list_controller.js +++ b/app/javascript/controllers/navigable_list_controller.js @@ -92,10 +92,11 @@ export default class extends Controller { event.preventDefault() } - #triggerActionOnCurrentItem() { - if (this.actionableItemsValue && this.currentItem) { + #triggerActionOnCurrentItem(event) { + if (this.actionableItemsValue && this.currentItem && this.#visibleItems.length) { const clickableElement = this.currentItem.querySelector("a,button") || this.currentItem clickableElement.click() + event.preventDefault() } } @@ -113,7 +114,7 @@ export default class extends Controller { this.#handleArrowKey(event, this.#selectPrevious.bind(this)) }, Enter(event) { - this.#triggerActionOnCurrentItem() + this.#triggerActionOnCurrentItem(event) } } } diff --git a/app/views/cards/taggings/new.html.erb b/app/views/cards/taggings/new.html.erb index e41bcf69d..a6f6ec65d 100644 --- a/app/views/cards/taggings/new.html.erb +++ b/app/views/cards/taggings/new.html.erb @@ -1,9 +1,16 @@ <%= turbo_frame_tag @card, :tagging do %> - + Tag this… <%= form_with url: card_taggings_path(@card), class: "flex gap-half align-center full-width pad-inline-half margin-block-end" do |form| %> - <%= form.text_field :tag_title, placeholder: "New tag name...", class: "input txt-small full-width", autocomplete: "off" %> + <%= form.text_field :tag_title, placeholder: "New tag name...", class: "input txt-small full-width", + autocomplete: "off", data: { filter_target: "input", action: "input->filter#filter" } %> <%= form.button "Add a tag…", type: "submit", class: "btn txt-small" do %> <%= icon_tag "add" %> Add a tag @@ -12,9 +19,10 @@