From d4ffae09da6802acd1c65167a532a29869899025 Mon Sep 17 00:00:00 2001 From: Yohan Boniface Date: Tue, 3 Sep 2024 16:53:47 +0200 Subject: [PATCH] feat: add throttling for text input elements --- umap/static/umap/js/umap.forms.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/umap/static/umap/js/umap.forms.js b/umap/static/umap/js/umap.forms.js index 8eb730eb..a2334c9a 100644 --- a/umap/static/umap/js/umap.forms.js +++ b/umap/static/umap/js/umap.forms.js @@ -241,6 +241,16 @@ L.FormBuilder.Element.include({ }, }) +L.FormBuilder.Input.include({ + set: function () { + // Add throttling + if (this._typing) window.clearTimeout(this._typing) + this._typing = window.setTimeout(() => { + this.builder.setter(this.field, this.toJS()) + }, 300) + }, +}) + L.FormBuilder.Select.include({ clear: function () { this.select.value = ''