Skip to content

Commit 02ad884

Browse files
committed
Add debouncing on filtering
1 parent 56c1536 commit 02ad884

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

src/Umbraco.Cms.Integrations.Crm.ActiveCampaign/Client/src/modal/activecampaign-forms-modal.element.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ export default class ActiveCampaignFormsModalElement
3232
@state()
3333
_searchQuery = "";
3434

35+
#filterTimeout?: NodeJS.Timeout;
36+
3537
constructor() {
3638
super();
3739

@@ -83,9 +85,15 @@ export default class ActiveCampaignFormsModalElement
8385
query = query.toLowerCase();
8486
this._searchQuery = query;
8587

86-
console.log('Filter query:', this._searchQuery);
88+
// Clear existing timeout
89+
if (this.#filterTimeout) {
90+
clearTimeout(this.#filterTimeout);
91+
}
8792

88-
await this.#loadForms(this._currentPageNumber, this._searchQuery);
93+
this.#filterTimeout = setTimeout(async () => {
94+
this._currentPageNumber = 1;
95+
await this.#loadForms(this._currentPageNumber, this._searchQuery);
96+
}, 2000);
8997
}
9098

9199
async #onPageChange(event: UUIPaginationEvent) {

0 commit comments

Comments
 (0)