Move dialog focus handling into the dialog controller
... instead of a separate dialog focus controller
This commit is contained in:
@@ -41,7 +41,7 @@ module FiltersHelper
|
||||
end
|
||||
|
||||
def filter_title(title)
|
||||
tag.strong title, class: "popup__title", tabindex: "-1", data: { dialog_focus_target: "touch" }
|
||||
tag.strong title, class: "popup__title", tabindex: "-1", data: { dialog_target: "focusTouch" }
|
||||
end
|
||||
|
||||
def collapsible_nav_section(title, **properties, &block)
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
import { Controller } from "@hotwired/stimulus"
|
||||
import { orient } from "helpers/orientation_helpers"
|
||||
import { isTouchDevice } from "helpers/platform_helpers"
|
||||
|
||||
export default class extends Controller {
|
||||
static targets = [ "dialog" ]
|
||||
static targets = [ "dialog", "focusMouse", "focusTouch" ]
|
||||
static values = {
|
||||
modal: { type: Boolean, default: false },
|
||||
sizing: { type: Boolean, default: true },
|
||||
@@ -10,6 +11,7 @@ export default class extends Controller {
|
||||
}
|
||||
|
||||
connect() {
|
||||
this.#setupFocus()
|
||||
this.dialogTarget.setAttribute("aria-hidden", "true")
|
||||
if (this.autoOpenValue) this.open()
|
||||
}
|
||||
@@ -63,4 +65,10 @@ export default class extends Controller {
|
||||
captureKey(event) {
|
||||
if (event.key !== "Escape") { event.stopPropagation() }
|
||||
}
|
||||
|
||||
#setupFocus() {
|
||||
const touch = isTouchDevice()
|
||||
if (this.hasFocusMouseTarget) this.focusMouseTarget.autofocus = !touch
|
||||
if (this.hasFocusTouchTarget) this.focusTouchTarget.autofocus = touch
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,16 +0,0 @@
|
||||
import { Controller } from "@hotwired/stimulus"
|
||||
import { isTouchDevice } from "helpers/platform_helpers"
|
||||
|
||||
export default class extends Controller {
|
||||
static targets = [ "mouse", "touch" ]
|
||||
|
||||
connect() {
|
||||
this.#setup()
|
||||
}
|
||||
|
||||
#setup() {
|
||||
const touch = isTouchDevice()
|
||||
if (this.hasMouseTarget) this.mouseTarget.autofocus = !touch
|
||||
if (this.hasTouchTarget) this.touchTarget.autofocus = touch
|
||||
}
|
||||
}
|
||||
@@ -18,7 +18,7 @@
|
||||
<%= filter_dialog "Board…" do %>
|
||||
<%= filter_title "Board…" %>
|
||||
<%= text_field_tag nil, nil, id: nil, placeholder: "Filter…", class: "input input--transparent txt-small font-weight-normal", autofocus: true,
|
||||
type: "search", autocorrect: "off", autocomplete: "off", data: { "1p-ignore": "true", filter_target: "input", dialog_focus_target: "mouse", action: "input->filter#filter" } %>
|
||||
type: "search", autocorrect: "off", autocomplete: "off", data: { "1p-ignore": "true", filter_target: "input", dialog_target: "focusMouse", action: "input->filter#filter" } %>
|
||||
|
||||
<ul class="popup__list" data-filter-target="list" role="listbox">
|
||||
<% user_filtering.boards.each do |board| %>
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
<%= filter_dialog "Person…" do %>
|
||||
<%= filter_title "Person…" %>
|
||||
<%= text_field_tag nil, nil, id: nil, placeholder: "Filter…", class: "input input--transparent txt-small font-weight-normal", autofocus: true,
|
||||
type: "search", autocorrect: "off", autocomplete: "off", data: { "1p-ignore": "true", filter_target: "input", dialog_focus_target: "mouse", action: "input->filter#filter" } %>
|
||||
type: "search", autocorrect: "off", autocomplete: "off", data: { "1p-ignore": "true", filter_target: "input", dialog_target: "focusMouse", action: "input->filter#filter" } %>
|
||||
|
||||
<ul class="popup__list" data-filter-target="list" role="listbox">
|
||||
<% user_filtering.users.each do |user| %>
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
<%= filter_title "Assigned to…" %>
|
||||
<% if Current.account.users.active.many? %>
|
||||
<%= text_field_tag nil, nil, id: nil, placeholder: "Filter…", class: "input input--transparent txt-small", autofocus: true,
|
||||
type: "search", autocorrect: "off", autocomplete: "off", data: { "1p-ignore": "true", filter_target: "input", dialog_focus_target: "mouse", action: "input->filter#filter" } %>
|
||||
type: "search", autocorrect: "off", autocomplete: "off", data: { "1p-ignore": "true", filter_target: "input", dialog_target: "focusMouse", action: "input->filter#filter" } %>
|
||||
<% end %>
|
||||
|
||||
<ul class="popup__list" data-filter-target="list" role="listbox">
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
<%= filter_title "Board…" %>
|
||||
<% if user_filtering.boards.many? %>
|
||||
<%= text_field_tag nil, nil, id: nil, placeholder: "Filter…", class: "input input--transparent txt-small", autofocus: true,
|
||||
type: "search", autocorrect: "off", autocomplete: "off", data: { "1p-ignore": "true", filter_target: "input", dialog_focus_target: "mouse", action: "input->filter#filter" } %>
|
||||
type: "search", autocorrect: "off", autocomplete: "off", data: { "1p-ignore": "true", filter_target: "input", dialog_target: "focusMouse", action: "input->filter#filter" } %>
|
||||
<% end %>
|
||||
|
||||
<ul class="popup__list" data-filter-target="list" role="listbox">
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
<%= filter_title "Closed by…" %>
|
||||
<% if user_filtering.users.many? %>
|
||||
<%= text_field_tag nil, nil, id: nil, placeholder: "Filter…", class: "input input--transparent txt-small", autofocus: true,
|
||||
type: "search", autocorrect: "off", autocomplete: "off", data: { "1p-ignore": "true", filter_target: "input", dialog_focus_target: "mouse", action: "input->filter#filter" } %>
|
||||
type: "search", autocorrect: "off", autocomplete: "off", data: { "1p-ignore": "true", filter_target: "input", dialog_target: "focusMouse", action: "input->filter#filter" } %>
|
||||
<% end %>
|
||||
|
||||
<ul class="popup__list" data-filter-target="list" role="listbox">
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
<%= filter_title "Added by…" %>
|
||||
<% if user_filtering.users.many? %>
|
||||
<%= text_field_tag nil, nil, id: nil, placeholder: "Filter…", class: "input input--transparent txt-small", autofocus: true,
|
||||
type: "search", autocorrect: "off", autocomplete: "off", data: { "1p-ignore": "true", filter_target: "input", dialog_focus_target: "mouse", action: "input->filter#filter" } %>
|
||||
type: "search", autocorrect: "off", autocomplete: "off", data: { "1p-ignore": "true", filter_target: "input", dialog_target: "focusMouse", action: "input->filter#filter" } %>
|
||||
<% end %>
|
||||
|
||||
<ul class="popup__list" data-filter-target="list" role="listbox">
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
<%= filter_title "Tagged…" %>
|
||||
<% if user_filtering.tags.many? %>
|
||||
<%= text_field_tag nil, nil, id: nil, placeholder: "Filter…", class: "input input--transparent txt-small", autofocus: true,
|
||||
type: "search", autocorrect: "off", autocomplete: "off", data: { "1p-ignore": "true", filter_target: "input", dialog_focus_target: "mouse", action: "input->filter#filter" } %>
|
||||
type: "search", autocorrect: "off", autocomplete: "off", data: { "1p-ignore": "true", filter_target: "input", dialog_target: "focusMouse", action: "input->filter#filter" } %>
|
||||
<% end %>
|
||||
|
||||
<ul class="popup__list" data-filter-target="list" role="listbox">
|
||||
|
||||
Reference in New Issue
Block a user