Merge pull request #1097 from basecamp/faster-filters

Submit and refresh results as you type terms
This commit is contained in:
Jorge Manrubia
2025-09-12 18:28:41 +02:00
committed by GitHub
5 changed files with 36 additions and 12 deletions
@@ -1,12 +1,30 @@
import { Controller } from "@hotwired/stimulus"
import { debounce } from "helpers/timing_helpers";
export default class extends Controller {
static targets = [ "cancel" ]
static values = {
debounceTimeout: { type: Number, default: 300 }
}
initialize() {
this.debouncedSubmit = debounce(this.debouncedSubmit.bind(this), this.debounceTimeoutValue)
}
submit() {
this.element.requestSubmit()
}
debouncedSubmit(event) {
this.submit(event)
}
submitToTopTarget(event) {
this.element.setAttribute("data-turbo-frame", "_top")
this.submit()
}
cancel() {
this.cancelTarget?.click()
}