From 898a3e93b2b188a2e6917053108b2e5cf7186b33 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexis=20M=C3=A9taireau?= Date: Mon, 13 May 2024 13:49:03 +0200 Subject: [PATCH] fix(sync): do not call `getSyncMetadata` if it doesn't exist This can arise when the form isn't bound to a "syncable" object. We might want to provide an utility to check an object is *syncable*, or a specific form to not attempt to sync objects which don't need it. --- umap/static/umap/js/umap.forms.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/umap/static/umap/js/umap.forms.js b/umap/static/umap/js/umap.forms.js index 99ebded4..04271a17 100644 --- a/umap/static/umap/js/umap.forms.js +++ b/umap/static/umap/js/umap.forms.js @@ -1186,8 +1186,10 @@ U.FormBuilder = L.FormBuilder.extend({ L.FormBuilder.prototype.setter.call(this, field, value) this.obj.isDirty = true if ('render' in this.obj) this.obj.render([field], this) - const { subject, metadata, engine } = this.obj.getSyncMetadata() - if (engine) engine.update(subject, metadata, field, value) + if ('getSyncMetadata' in this.obj) { + const { subject, metadata, engine } = this.obj.getSyncMetadata() + if (engine) engine.update(subject, metadata, field, value) + } }, finish: function () {