From 6bb7cd79037e44333b52b1b8f19af7fc5854aa1e Mon Sep 17 00:00:00 2001 From: Cameron Dutro Date: Thu, 7 Nov 2024 10:17:42 -0800 Subject: [PATCH 1/2] [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( From 0bdae85c12776f90fd89f0fa6f6c6e7b220b0abc Mon Sep 17 00:00:00 2001 From: Cameron Dutro Date: Thu, 7 Nov 2024 10:59:22 -0800 Subject: [PATCH 2/2] Add changeset --- .changeset/silent-wasps-peel.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/silent-wasps-peel.md diff --git a/.changeset/silent-wasps-peel.md b/.changeset/silent-wasps-peel.md new file mode 100644 index 0000000000..ae576fb25a --- /dev/null +++ b/.changeset/silent-wasps-peel.md @@ -0,0 +1,5 @@ +--- +'@primer/view-components': patch +--- + +[SelectPanel] Don't clear selection if input field doesn't exist