From d420d8d8ac34b7709337ac8eaa5279d3fdafca97 Mon Sep 17 00:00:00 2001 From: Jason Zimdars Date: Thu, 26 Jun 2025 16:56:27 -0500 Subject: [PATCH] Add keyboard navigation and filtering to quick filters --- app/assets/stylesheets/filters.css | 2 +- app/assets/stylesheets/popup.css | 2 +- app/views/filters/_assignees.html.erb | 108 ++++++++++++++++--------- app/views/filters/_creators.html.erb | 90 +++++++++++---------- app/views/filters/_indexed_by.html.erb | 56 +++++++------ app/views/filters/_tags.html.erb | 75 ++++++++++------- 6 files changed, 194 insertions(+), 139 deletions(-) diff --git a/app/assets/stylesheets/filters.css b/app/assets/stylesheets/filters.css index d89ad57f1..45be28002 100644 --- a/app/assets/stylesheets/filters.css +++ b/app/assets/stylesheets/filters.css @@ -98,7 +98,7 @@ } .quick-filter { - &:has(input:not(.default-value):checked) { + &:not(.default-value):has(.checked) { .input--select { --input-background: var(--color-selected); } diff --git a/app/assets/stylesheets/popup.css b/app/assets/stylesheets/popup.css index 0d1c27807..addd87f2d 100644 --- a/app/assets/stylesheets/popup.css +++ b/app/assets/stylesheets/popup.css @@ -94,7 +94,7 @@ } &:has(input:checked) { - --btn-background: var(--color-ink-lightest); + --btn-background: transparent; --btn-color: var(--color-ink); .icon { diff --git a/app/views/filters/_assignees.html.erb b/app/views/filters/_assignees.html.erb index 9dc4a87a0..1a1e33926 100644 --- a/app/views/filters/_assignees.html.erb +++ b/app/views/filters/_assignees.html.erb @@ -5,53 +5,81 @@ <% if filter.assignment_status.unassigned? %> No one <% elsif filter.assignees.any? %> - Assigned to <%= filter.assignees.map(&:familiar_name).to_sentence %> + Assigned to <%= filter.assignees.map(&:familiar_name).to_sentence(two_words_connector: " or ", last_word_connector: ", or ") %> <% else %> Assigned to… <% end %> - - Assigned to… - <%= form_with url: cards_path, method: :get, class: "popup__list", - data: { controller: "form" } do |form| %> - <% filter.as_params.except(:assignee_ids, :assignment_status).each do |key, value| %> - <%= filter_hidden_field_tag key, value %> - <% end %> + <%= tag.dialog class: "margin-block-start-half popup panel flex-column align-start gap-half fill-white shadow txt-small", data: { + action: "turbo:before-cache@document->dialog#close keydown->navigable-list#navigate filter:changed->navigable-list#reset toggle->filter#filter", + aria: { label: "Assigned to…", aria_description: "Assigned to…" }, + controller: "filter navigable-list", + dialog_target: "dialog", + navigable_list_focus_on_selection_value: false, + navigable_list_actionable_items_value: true } do %> + Assigned to… - <% if @expand_all %> - <%= hidden_field_tag :expand_all, @expand_all %> - <% end %> - - <%= link_to cards_path(filter.as_params.except(:assignee_ids, :assignment_status).merge(expand_all: @expand_all)), class: "btn popup__item" do %> - Deselect all - <% end %> - - - - <% User.active.order(:name).each do |user| %> - - <% end %> + <% if User.active.many? %> + <%= text_field_tag :search, nil, placeholder: "Filter…", class: "input input--transparent txt-small", autofocus: true, + type: "search", autocorrect: "off", autocomplete: "off", data: { "1p-ignore": "true", filter_target: "input", action: "input->filter#filter" } %> <% end %> - + + + <% end %> <% end %> diff --git a/app/views/filters/_creators.html.erb b/app/views/filters/_creators.html.erb index 3db8d63d6..9ba8954e7 100644 --- a/app/views/filters/_creators.html.erb +++ b/app/views/filters/_creators.html.erb @@ -4,57 +4,59 @@ - - Added by… - <%= form_with url: cards_path, method: :get, class: "popup__list", - data: { controller: "form" } do |form| %> - <% filter.as_params.except(:creator_ids).each do |key, value| %> - <%= filter_hidden_field_tag key, value %> - <% end %> + <%= tag.dialog class: "margin-block-start-half popup panel flex-column align-start gap-half fill-white shadow txt-small", data: { + action: "turbo:before-cache@document->dialog#close keydown->navigable-list#navigate filter:changed->navigable-list#reset toggle->filter#filter", + aria: { label: "Added by…", aria_description: "Added by…" }, + controller: "filter navigable-list", + dialog_target: "dialog", + navigable_list_focus_on_selection_value: false, + navigable_list_actionable_items_value: true } do %> + Added by… - <% if @expand_all %> - <%= hidden_field_tag :expand_all, @expand_all %> - <% end %> - - <%= link_to cards_path(filter.as_params.except(:creator_ids).merge(expand_all: @expand_all)), class: "btn popup__item" do %> - Deselect all - <% end %> - - - - <% User.active.without(Current.user).order(:name).each do |user| %> - - <% end %> + <% if User.active.many? %> + <%= text_field_tag :search, nil, placeholder: "Filter…", class: "input input--transparent txt-small", autofocus: true, + type: "search", autocorrect: "off", autocomplete: "off", data: { "1p-ignore": "true", filter_target: "input", action: "input->filter#filter" } %> <% end %> - + + + <% end %> <% end %> diff --git a/app/views/filters/_indexed_by.html.erb b/app/views/filters/_indexed_by.html.erb index 091252cf5..37a22388f 100644 --- a/app/views/filters/_indexed_by.html.erb +++ b/app/views/filters/_indexed_by.html.erb @@ -1,36 +1,44 @@ <% if !filter.indexed_by.latest? || @expand_all %> -
+
" data-controller="dialog" data-action="keydown.esc->dialog#close click@document->dialog#closeOnClickOutside"> - - Sort by… - <%= form_with url: cards_path, method: :get, class: "popup__list", - data: { controller: "form" } do |form| %> - <% filter.as_params.except(:indexed_by).each do |key, value| %> - <%= filter_hidden_field_tag key, value %> - <% end %> - - <% if @expand_all %> - <%= hidden_field_tag :expand_all, @expand_all %> - <% end %> - + <%= tag.dialog class: "margin-block-start-half popup panel flex-column align-start gap-half fill-white shadow txt-small", data: { + action: "turbo:before-cache@document->dialog#close keydown->navigable-list#navigate", + aria: { label: "Sort by…", aria_description: "Sort by…" }, + controller: "navigable-list", + dialog_target: "dialog", + navigable_list_focus_on_selection_value: false, + navigable_list_actionable_items_value: true } do %> + Sort by… + + + + <% end %>
<% end %> diff --git a/app/views/filters/_tags.html.erb b/app/views/filters/_tags.html.erb index 2cc76c340..665d1f048 100644 --- a/app/views/filters/_tags.html.erb +++ b/app/views/filters/_tags.html.erb @@ -3,42 +3,59 @@ - - Tagged… - <%= form_with url: cards_path, method: :get, class: "popup__list", - data: { controller: "form" } do |form| %> - <% filter.as_params.except(:tag_ids).each do |key, value| %> - <%= filter_hidden_field_tag key, value %> - <% end %> + <%= tag.dialog class: "margin-block-start-half popup panel flex-column align-start gap-half fill-white shadow txt-small", data: { + action: "turbo:before-cache@document->dialog#close keydown->navigable-list#navigate filter:changed->navigable-list#reset toggle->filter#filter", + aria: { label: "Tagged…", aria_description: "Tagged…" }, + controller: "filter navigable-list", + dialog_target: "dialog", + navigable_list_focus_on_selection_value: false, + navigable_list_actionable_items_value: true } do %> + Tagged… - <% if @expand_all %> - <%= hidden_field_tag :expand_all, @expand_all %> - <% end %> - - <%= link_to cards_path(filter.as_params.except(:tag_ids).merge(expand_all: @expand_all)), class: "btn popup__item" do %> - Clear all - <% end %> - - <% Tag.order(:title).each do |tag| %> - - <% end %> + <% if Tag.many? %> + <%= text_field_tag :search, nil, placeholder: "Filter…", class: "input input--transparent txt-small", autofocus: true, + type: "search", autocorrect: "off", autocomplete: "off", data: { "1p-ignore": "true", filter_target: "input", action: "input->filter#filter" } %> <% end %> - + + + <% end %>
<% end %>