HTTP request triggered by event 'blur' when changing page may not finish #2

Open
opened 2025-04-08 08:13:31 +02:00 by gburri · 1 comment
Owner

When editing a recipe and changing a field (like description) and then clicking any link on the page the field update HTTP request will be triggered and may not finished before unloading the page.

EventListener::new(&description.clone(), "blur", move |_event| {

When editing a recipe and changing a field (like description) and then clicking any link on the page the field update HTTP request will be triggered and may not finished before unloading the page. https://git.gburri.org/gburri/recipes/src/commit/182c951fd2b1f7c7c5e6a7ef3290750741d28224/frontend/src/pages/recipe_edit.rs#L51
gburri changed title from Event *blur* triggers a request when changing page to HTTP request triggered by event 'blur' when changing page may not finish 2025-04-08 08:15:10 +02:00
gburri added the
Kind/Bug
label 2025-04-08 08:15:30 +02:00
Author
Owner

Some points:

Some points: * We can't block the callback 'beforeunload' : https://developer.mozilla.org/en-US/docs/Web/API/Window/unload_event * But we may cancel the page unload with a message if the request is not finished * Maybe use ServiceWorker : https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorker
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: gburri/recipes#2
No description provided.