Skip to content

Commit

Permalink
Add delay on reload handler to prevent early fireing of restore
Browse files Browse the repository at this point in the history
  • Loading branch information
jrief committed May 7, 2024
1 parent 0124c14 commit f0b5877
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion client/django-formset/DjangoFormset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -629,7 +629,9 @@ class DjangoButton {
private reload(includeQuery?: Boolean) {
return (response: Response) => {
includeQuery ? location.reload() : location.replace(window.location.pathname);
return Promise.resolve(response);
// since the current page usually is reloaded before this promise resolves, add a delay
// to prevent the restore handler from being called before the page is reloaded.
return new Promise(resolve => window.setTimeout(() => resolve(response), 3000));
};
}

Expand Down

0 comments on commit f0b5877

Please sign in to comment.