From 6bb7cd79037e44333b52b1b8f19af7fc5854aa1e Mon Sep 17 00:00:00 2001 From: Cameron Dutro Date: Thu, 7 Nov 2024 10:17:42 -0800 Subject: [PATCH] [SelectPanel] Don't clear selection if input field doesn't exist --- app/components/primer/alpha/select_panel_element.ts | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/app/components/primer/alpha/select_panel_element.ts b/app/components/primer/alpha/select_panel_element.ts index 23f6d3e44f..f390b1cf41 100644 --- a/app/components/primer/alpha/select_panel_element.ts +++ b/app/components/primer/alpha/select_panel_element.ts @@ -465,10 +465,13 @@ export class SelectPanelElement extends HTMLElement { this.dialog.removeAttribute('data-ready') this.invokerElement?.setAttribute('aria-expanded', 'false') // When we close the dialog, clear the filter input - const fireSearchEvent = this.filterInputTextField.value.length > 0 - this.filterInputTextField.value = '' - if (fireSearchEvent) { - this.filterInputTextField.dispatchEvent(new Event('input')) + + if (this.filterInputTextField) { + const fireSearchEvent = this.filterInputTextField.value.length > 0 + this.filterInputTextField.value = '' + if (fireSearchEvent) { + this.filterInputTextField.dispatchEvent(new Event('input')) + } } this.dispatchEvent(