Skip to content

Commit 3cb8c08

Browse files
committed
Add debouncing feature
1 parent b8f07f0 commit 3cb8c08

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

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

Lines changed: 11 additions & 1 deletion
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,7 +85,15 @@ export default class ActiveCampaignFormsModalElement
8385
query = query.toLowerCase();
8486
this._searchQuery = query;
8587

86-
await this.#loadForms(this._currentPageNumber, this._searchQuery);
88+
// Clear existing timeout
89+
if (this.#filterTimeout) {
90+
clearTimeout(this.#filterTimeout);
91+
}
92+
93+
this.#filterTimeout = setTimeout(async () => {
94+
this._currentPageNumber = 1;
95+
await this.#loadForms(this._currentPageNumber, this._searchQuery);
96+
}, 2000);
8797
}
8898

8999
async #onPageChange(event: UUIPaginationEvent) {

0 commit comments

Comments
 (0)