diff --git a/app/components/primer/alpha/select_panel_element.ts b/app/components/primer/alpha/select_panel_element.ts index dfe16f3081..2e0cfd5bea 100644 --- a/app/components/primer/alpha/select_panel_element.ts +++ b/app/components/primer/alpha/select_panel_element.ts @@ -759,7 +759,10 @@ export class SelectPanelElement extends HTMLElement { #setErrorState(type: ErrorStateType) { let errorElement = this.bodyErrorMessage - if (type === ErrorStateType.BODY) { + // If the error type is BODY but the body error message element doesn't exist, + // that means the no items/results message is showing, so the error needs to be + // shown in banner form instead. + if (type === ErrorStateType.BODY && this.bodyErrorMessage) { this.bodyErrorMessage?.removeAttribute('hidden') this.bannerErrorMessage.setAttribute('hidden', '') } else { diff --git a/test/system/alpha/select_panel_test.rb b/test/system/alpha/select_panel_test.rb index b7dc731fb5..e74f0bad3e 100644 --- a/test/system/alpha/select_panel_test.rb +++ b/test/system/alpha/select_panel_test.rb @@ -1075,15 +1075,15 @@ def test_no_results_filter_failure end # no items on initial load - assert_selector "select-panel", text: "No results found" + assert_selector "select-panel", text: "No items found" wait_for_items_to_load do filter_results(query: "foobar") end # only the banner-based error message should appear - assert_selector "[data-target='select-panel.bannerErrorElement']", text: "Sorry, something went wrong" - refute_selector "[data-target='select-panel.fragmentErrorElement']" + assert_selector "[data-target='select-panel.bannerErrorMessage']", text: "Sorry, something went wrong" + refute_selector "[data-target='select-panel.bodyErrorMessage']" end def test_remote_fetch_clears_input_on_close