FIX: Disable filter when loading tags in edit nav menu tags modal (#23789)

Why this change?

When we're in the midst of loading more tags, the filter dropdown
is still enabled and may result in us firing off multiple requests to
the server to load more tags. This makes the loading hard to reason
about in the tests environment and has led to flaky tests.

What does this change do?

This changes disables the filter dropdown when more tags are being
loading.
This commit is contained in:
Alan Guo Xiang Tan 2023-10-23 08:35:40 +08:00 committed by GitHub
parent f2a90afa4c
commit 8c07bbe084
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 16 additions and 4 deletions

View File

@ -40,7 +40,7 @@
@value={{this.filterDropdownValue}}
@content={{this.filterDropdownContent}}
@onChange={{this.onFilterDropdownChange}}
@options={{hash showCaret=true}}
@options={{hash showCaret=true disabled=@loading}}
/>
</div>
</div>

View File

@ -16,6 +16,7 @@
@filterSelected={{this.filterSelected}}
@filterUnselected={{this.filterUnselected}}
@closeModal={{@closeModal}}
@loading={{this.tagsLoading}}
>
{{#if this.tagsLoading}}
{{loading-spinner size="large"}}

View File

@ -15,7 +15,7 @@ export default class extends Component {
@tracked onlySelected = false;
@tracked onlyUnSelected = false;
@tracked tags = [];
@tracked tagsLoading = true;
@tracked tagsLoading;
@tracked selectedTags = [...this.currentUser.sidebarTagNames];
constructor() {
@ -43,11 +43,13 @@ export default class extends Component {
await this.store
.findAll("listTag", findArgs)
.then((tags) => {
this.tagsLoading = false;
this.tags = tags;
})
.catch((error) => {
popupAjaxError(error);
})
.finally(() => {
this.tagsLoading = false;
});
}

View File

@ -157,6 +157,9 @@ RSpec.describe "Editing sidebar tags navigation", type: :system do
expect(sidebar).to have_tags_section
modal = sidebar.click_edit_tags_button
expect(modal).to have_tag_checkboxes([tag1, tag2, tag3, tag4])
modal.filter_by_selected
expect(modal).to have_tag_checkboxes([tag1, tag2])

View File

@ -38,6 +38,10 @@ module PageObjects
has_css?(context + ":not(.is-expanded)", wait: 0)
end
def is_not_disabled?
has_css?(@context + ":not(.disabled)", wait: 0)
end
def has_selected_value?(value)
component.find(".select-kit-header[data-value='#{value}']")
end

View File

@ -67,7 +67,9 @@ module PageObjects
private
def dropdown_filter
PageObjects::Components::SelectKit.new(".sidebar__edit-navigation-menu__filter-dropdown")
PageObjects::Components::SelectKit.new(
".sidebar__edit-navigation-menu__filter-dropdown",
).tap(&:is_not_disabled?)
end
end
end