From a703e5efce9a6b469154528e381a9906f43b55b0 Mon Sep 17 00:00:00 2001 From: Rainer Dema Date: Mon, 4 Dec 2023 17:14:13 +0100 Subject: [PATCH] Add conditional focus behavior to search field after filter selection --- admin/app/components/solidus_admin/ui/table/component.js | 7 +++++-- .../solidus_admin/ui/table/ransack_filter/component.js | 5 +++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/admin/app/components/solidus_admin/ui/table/component.js b/admin/app/components/solidus_admin/ui/table/component.js index db605cca934..f9b2b0d935f 100644 --- a/admin/app/components/solidus_admin/ui/table/component.js +++ b/admin/app/components/solidus_admin/ui/table/component.js @@ -42,10 +42,13 @@ export default class extends Controller { } } - showSearch(event) { + showSearch({ detail: { focus } }) { this.modeValue = "search" this.render() - this.searchFieldTarget.focus() + + if (focus ?? true) { + this.searchFieldTarget.focus() + } } search() { diff --git a/admin/app/components/solidus_admin/ui/table/ransack_filter/component.js b/admin/app/components/solidus_admin/ui/table/ransack_filter/component.js index 106133d0292..5652c17e7c7 100644 --- a/admin/app/components/solidus_admin/ui/table/ransack_filter/component.js +++ b/admin/app/components/solidus_admin/ui/table/ransack_filter/component.js @@ -29,8 +29,9 @@ export default class extends Controller { } showSearch() { - if (this.isAnyCheckboxChecked()) - this.dispatch("showSearch") + if (this.isAnyCheckboxChecked()) { + this.dispatch("showSearch", { detail: { focus: false } }) + } } filterOptions(event) {