Refactor
This commit is contained in:
@@ -22,12 +22,6 @@ export default class extends Controller {
|
||||
this.#hideItem(this.searchTarget)
|
||||
}
|
||||
|
||||
clearInput(event) {
|
||||
if (event.detail.isAlreadyEmpty) {
|
||||
this.reset()
|
||||
}
|
||||
}
|
||||
|
||||
showModalAndSubmit(event) {
|
||||
this.showModal()
|
||||
this.formTarget.requestSubmit()
|
||||
|
||||
@@ -4,14 +4,11 @@ export default class extends Controller {
|
||||
static targets = ["searchInput"]
|
||||
|
||||
clearInput() {
|
||||
this.dispatch("clear", { detail: { isAlreadyEmpty: this.isEmpty } })
|
||||
if (!this.isEmpty) {
|
||||
if (this.searchInputTarget.value) {
|
||||
this.searchInputTarget.value = ""
|
||||
this.searchInputTarget.focus()
|
||||
} else {
|
||||
this.dispatch("reset")
|
||||
}
|
||||
}
|
||||
|
||||
get isEmpty() {
|
||||
return !this.searchInputTarget.value
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user