diff --git a/app/components/list_filter_component.html.erb b/app/components/list_filter_component.html.erb index d5f5fa9039..6bed1b42a7 100644 --- a/app/components/list_filter_component.html.erb +++ b/app/components/list_filter_component.html.erb @@ -56,7 +56,7 @@ > 0) { + this.tagsTarget.insertBefore( + this.#formatTag(this.inputTarget.value), + this.inputTarget, + ); + this.inputTarget.value = ""; + } this.#updateCount(); } @@ -68,7 +74,6 @@ export default class extends Controller { const text = last.querySelector(".label").innerText; this.tagsTarget.removeChild(last); this.inputTarget.value = text; - this.#addDelayed(); } #getNamesAndPUID(value) { @@ -91,14 +96,6 @@ export default class extends Controller { return clone; } - #addDelayed = _.debounce(() => { - const value = this.inputTarget.value.trim(); - if (value.length > 0 && value !== ",") { - this.tagsTarget.insertBefore(this.#formatTag(value), this.inputTarget); - this.#clearAndFocus(); - } - }, 1000); - #updateCount() { const count = this.tagsTarget.querySelectorAll(".search-tag").length; if (count > 0) { diff --git a/test/components/viral/system/list_filter_component_test.rb b/test/components/viral/system/list_filter_component_test.rb index e0d68eb09b..237aa230e7 100644 --- a/test/components/viral/system/list_filter_component_test.rb +++ b/test/components/viral/system/list_filter_component_test.rb @@ -14,9 +14,9 @@ class ListFilterComponentTest < ApplicationSystemTestCase within 'dialog' do assert_selector 'h1', text: I18n.t(:'components.list_filter.title') fill_in I18n.t(:'components.list_filter.description'), with: "#{puid1}, #{puid2}" - assert_selector 'span.label', count: 2 + assert_selector 'span.label', count: 1 assert_selector 'span.label', text: puid1 - assert_selector 'span.label', text: puid2 + find('input').text puid2 click_button I18n.t(:'components.list_filter.apply') end assert_selector 'div[data-list-filter-target="count"]', text: '2' @@ -24,7 +24,11 @@ class ListFilterComponentTest < ApplicationSystemTestCase click_button I18n.t(:'components.list_filter.title') within 'dialog' do assert_selector 'h1', text: I18n.t(:'components.list_filter.title') + assert_selector 'span.label', count: 2 + assert_selector 'span.label', text: puid1 + assert_selector 'span.label', text: puid2 click_button I18n.t(:'components.list_filter.clear') + assert_selector 'span.label', count: 0 click_button I18n.t(:'components.list_filter.apply') end assert_no_selector 'div[data-list-filter-target="count"]' diff --git a/test/system/groups/samples_test.rb b/test/system/groups/samples_test.rb index 3c08979d8b..f9a349c8db 100644 --- a/test/system/groups/samples_test.rb +++ b/test/system/groups/samples_test.rb @@ -358,10 +358,10 @@ def retrieve_puids find("button[aria-label='#{I18n.t(:'components.list_filter.title')}").click within 'dialog' do assert_selector 'h1', text: I18n.t(:'components.list_filter.title') - find("input[type='text']").send_keys "#{@sample1.puid}, #{@sample2.puid}" - assert_selector 'span.label', count: 2 + find("input[name='q[name_or_puid_in][]']").send_keys "#{@sample1.puid}, #{@sample2.puid}" + assert_selector 'span.label', count: 1 assert_selector 'span.label', text: @sample1.puid - assert_selector 'span.label', text: @sample2.puid + find("input[name='q[name_or_puid_in][]']").text @sample2.puid click_button I18n.t(:'components.list_filter.apply') end diff --git a/test/system/projects/samples_test.rb b/test/system/projects/samples_test.rb index 444a3eda66..879c1ea834 100644 --- a/test/system/projects/samples_test.rb +++ b/test/system/projects/samples_test.rb @@ -2052,9 +2052,9 @@ class SamplesTest < ApplicationSystemTestCase within '#list-filter-dialog' do assert_selector 'h1', text: I18n.t(:'components.list_filter.title') fill_in I18n.t(:'components.list_filter.description'), with: "#{@sample1.puid}, #{@sample2.puid}" - assert_selector 'span.label', count: 2 + assert_selector 'span.label', count: 1 assert_selector 'span.label', text: @sample1.puid - assert_selector 'span.label', text: @sample2.puid + find("input[name='q[name_or_puid_in][]']").text @sample2.puid click_button I18n.t(:'components.list_filter.apply') end within '#samples-table table tbody' do