Skip to content

Commit

Permalink
Initial commit for clearing input on SelectPanel
Browse files Browse the repository at this point in the history
  • Loading branch information
owenniblock committed Sep 17, 2024
1 parent 0ffe014 commit 881adb0
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .changeset/sweet-donkeys-allow.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@primer/view-components': patch
---

Clear input on SelectPanel when dialog closed
2 changes: 2 additions & 0 deletions app/components/primer/alpha/select_panel_element.ts
Original file line number Diff line number Diff line change
Expand Up @@ -935,6 +935,8 @@ export class SelectPanelElement extends HTMLElement {
}

hide() {
// When we close the dialog, clear the filter input
this.filterInputTextField.value = ''
this.dialog.close()
}

Expand Down
18 changes: 18 additions & 0 deletions test/system/alpha/select_panel_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -435,6 +435,24 @@ def test_single_selected_item_cannot_be_unchecked
refute_selector "[aria-checked]", visible: :hidden
end

def test_single_select_clears_input_on_close
visit_preview(:single_select)

click_on_invoker_button

filter_results(query: "it")

# keyboard.type(:enter)
click_on "Item 1"

assert_selector "[aria-selected=true]", text: "Item 1", visible: :hidden

click_on_invoker_button

# Check that the input value is empty
assert_selector "select-panel input", text: ""
end

def test_single_select_disabled_item_cannot_be_checked
visit_preview(:single_select)

Expand Down

0 comments on commit 881adb0

Please sign in to comment.