Skip to content

Commit

Permalink
ApiWrapper.vue: fix autosave
Browse files Browse the repository at this point in the history
In commit 24dc4bf the debouncedSave method was moved from
computed to the methods, where it seems to belong.
But the lodash debounce function returns a function, which
delays the invocation of the func when called, but does not directly
schedule the delayed function execution.
The caller has to do that by calling the returned function.
This apparently was done by vue before commit 24dc4bf,
because it was a computed property.

closes ecamp#3839
  • Loading branch information
BacLuc committed Sep 25, 2023
1 parent a20d87c commit 27a4077
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion frontend/src/components/form/api/ApiWrapper.vue
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ export default {
}
},
debouncedSave() {
return debounce(this.save, this.autoSaveDelay)
return debounce(this.save, this.autoSaveDelay).call()
},
// reload data from API (doesn't force loading from server if available locally)
reload() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@ vi.mock('lodash', async (importOriginal) => {
const lodash = await importOriginal()
return {
...lodash,
debounce: (callback) => new Promise((resolve) => (debounce = resolve)).then(callback),
debounce: (callback) =>
function () {
return new Promise((resolve) => (debounce = resolve)).then(callback)
},
set: lodash.set,
get: lodash.get,
}
Expand Down

0 comments on commit 27a4077

Please sign in to comment.