From e2faf473153ee65fe085dc78f8fb412a9510376d Mon Sep 17 00:00:00 2001 From: David Grudl Date: Sun, 9 Aug 2026 19:20:40 +0200 Subject: [PATCH] Autosubmit: configurable debounce delay The 200ms delay was hardcoded, which is short for filters over a slower backend - the request leaves while the user is still typing the word. Changing it meant copying the whole plugin, so the delay is now an optional constructor argument: new AutosubmitPlugin(500). Left out, the debounce() default applies as before. --- assets/plugins/features/autosubmit.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/assets/plugins/features/autosubmit.ts b/assets/plugins/features/autosubmit.ts index 540e347ef..206fd825e 100644 --- a/assets/plugins/features/autosubmit.ts +++ b/assets/plugins/features/autosubmit.ts @@ -9,6 +9,9 @@ export const AutosubmitPerPageAttribute = "data-autosubmit-per-page"; export const AutosubmitChangeAttribute = "data-autosubmit-change"; export class AutosubmitPlugin implements DatagridPlugin { + constructor(private delay?: number) { + } + onDatagridInit(datagrid: Datagrid): boolean { datagrid.ajax.addEventListener('complete', (event) => { this.initPerPage(datagrid); @@ -62,7 +65,7 @@ export class AutosubmitPlugin implements DatagridPlugin { if (submitEl.hasAttribute(AutosubmitChangeAttribute)) { submitEl.addEventListener( "change", - debounce(() => datagrid.ajax.submitForm(form)) + debounce(() => datagrid.ajax.submitForm(form), this.delay) ); } @@ -75,7 +78,7 @@ export class AutosubmitPlugin implements DatagridPlugin { } return datagrid.ajax.submitForm(form); - }) + }, this.delay) ); } });