mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-27 01:43:22 +00:00
TODO: optimise and fix bug
This commit is contained in:
@@ -55,6 +55,7 @@ export default class BulkFormController extends Controller {
|
||||
|
||||
toggleFormChanged() {
|
||||
// For each record, check if any fields are changed
|
||||
// TODO: optimise basd on current state. if field is changed, but form already changed, no need to update (and vice versa)
|
||||
const changedRecordCount = Object.values(this.recordElements).filter((elements) =>
|
||||
elements.some(this.#isChanged)
|
||||
).length;
|
||||
@@ -73,7 +74,7 @@ export default class BulkFormController extends Controller {
|
||||
|
||||
// Prevent accidental data loss
|
||||
if (formChanged) {
|
||||
window.addEventListener("beforeunload", this.preventLeavingBulkForm);
|
||||
window.addEventListener("beforeunload", this.preventLeavingBulkForm); // TOFIX: what if it has laredy been added? we can optimise above to avoid this
|
||||
} else {
|
||||
window.removeEventListener("beforeunload", this.preventLeavingBulkForm);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user