Skip to content

Commit

Permalink
Refactor event dispatching in Stimulus controllers
Browse files Browse the repository at this point in the history
Switched from using `stimulus-use` dispatch to explicit bubbling.
While using `stimulus-use`, targeting an upstream controller without
specifying the controller's name wasn't feasible in this context.
I've reverted to explicitly setting the event's bubbling property.
  • Loading branch information
rainerdema authored and elia committed Oct 10, 2023
1 parent 85463f8 commit 55217e4
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 10 deletions.
8 changes: 0 additions & 8 deletions admin/app/components/solidus_admin/ui/table/component.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,6 @@ export default class extends Controller {
}

connect() {
// this.element.addEventListener("ui--table--ransack-filter:search", () => this.search())
// this.element.addEventListener("ui--table--ransack-filter:showSearch", () => this.showSearch())

if (this.searchFieldTarget.value !== "") this.modeValue = "search"

this.render()
Expand Down Expand Up @@ -118,9 +115,4 @@ export default class extends Controller {
else if (selectedRows.length > 0) checkbox.indeterminate = true
})
}

// disconnect() {
// this.element.removeEventListener("ui--table--ransack-filter:showSearch", () => this.showSearch())
// this.element.removeEventListener("ui--table--ransack-filter:search", () => this.search())
// }
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ export default class extends Controller {
}

showSearch() {
if (this.isAnyCheckboxChecked()) this.dispatch('showSearch')
if (this.isAnyCheckboxChecked())
this.dispatch("showSearch")
}

filterOptions(event) {
Expand All @@ -39,7 +40,7 @@ export default class extends Controller {
}

search() {
this.dispatch('search')
this.dispatch("search")
this.highlightFilter()
}

Expand Down

0 comments on commit 55217e4

Please sign in to comment.