Skip to content

Commit 4d46a3a

Browse files
authored
[SelectPanel] Don't clear selection if input field doesn't exist (#3186)
1 parent 8e15cd4 commit 4d46a3a

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

.changeset/silent-wasps-peel.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@primer/view-components': patch
3+
---
4+
5+
[SelectPanel] Don't clear selection if input field doesn't exist

app/components/primer/alpha/select_panel_element.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -465,10 +465,13 @@ export class SelectPanelElement extends HTMLElement {
465465
this.dialog.removeAttribute('data-ready')
466466
this.invokerElement?.setAttribute('aria-expanded', 'false')
467467
// When we close the dialog, clear the filter input
468-
const fireSearchEvent = this.filterInputTextField.value.length > 0
469-
this.filterInputTextField.value = ''
470-
if (fireSearchEvent) {
471-
this.filterInputTextField.dispatchEvent(new Event('input'))
468+
469+
if (this.filterInputTextField) {
470+
const fireSearchEvent = this.filterInputTextField.value.length > 0
471+
this.filterInputTextField.value = ''
472+
if (fireSearchEvent) {
473+
this.filterInputTextField.dispatchEvent(new Event('input'))
474+
}
472475
}
473476

474477
this.dispatchEvent(

0 commit comments

Comments
 (0)