Skip to content

Commit

Permalink
Fix empty option not clearing select
Browse files Browse the repository at this point in the history
  • Loading branch information
hjr265 committed Feb 17, 2024
1 parent 6e745e6 commit 7769127
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/widgets/dropdown/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ class Dropdown {

if (select.multiple) {
if (empty) {
select.innerHTML = ''
select.innerHTML = ''
this.renderToggle()
return
}
Expand Down Expand Up @@ -211,7 +211,7 @@ class Dropdown {
const item = this.makeItem(data)

dom.on(item, 'click', () => {
if (!select.multiple) select.value = option.getAttribute('value')
if (!select.multiple || option.dataset.empty) select.value = option.getAttribute('value')
else option.selected = !option.selected

select.dispatchEvent(new Event('change', {
Expand Down

0 comments on commit 7769127

Please sign in to comment.