Skip to content

Commit

Permalink
feat(ld-select): clear selection with minus key
Browse files Browse the repository at this point in the history
  • Loading branch information
borisdiakur committed Jul 2, 2021
1 parent cc20a5b commit a6e566e
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/liquid/components/ld-select/ld-select.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,15 @@ export class LdSelect {
this.updateInert()
}

private clearSelection() {
Array.from(this.popperRef.querySelectorAll('ld-option')).forEach(
(option) => {
option.selected = false
}
)
this.selected = []
}

@Listen('resize', { target: 'window', passive: true })
handleWindowResize() {
this.updatePopperWidth()
Expand Down Expand Up @@ -333,6 +342,13 @@ export class LdSelect {
ev.stopImmediatePropagation()
}
break
case '-':
// Clear selection.
ev.preventDefault()
ev.stopImmediatePropagation()
this.clearSelection()
this.triggerRef.focus()
break
}

// TODO: implement type-ahead
Expand Down

0 comments on commit a6e566e

Please sign in to comment.