Skip to content

Commit

Permalink
[SelectPanel] Don't clear selection if input field doesn't exist (#3186)
Browse files Browse the repository at this point in the history
  • Loading branch information
camertron authored Nov 7, 2024
1 parent 8e15cd4 commit 4d46a3a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
5 changes: 5 additions & 0 deletions .changeset/silent-wasps-peel.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@primer/view-components': patch
---

[SelectPanel] Don't clear selection if input field doesn't exist
11 changes: 7 additions & 4 deletions app/components/primer/alpha/select_panel_element.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down

0 comments on commit 4d46a3a

Please sign in to comment.