From 190c3535fed363f01b9de3ce7988461c604ce4da 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 a37056cd..bca48214 100644 --- a/umap/static/umap/js/umap.forms.js +++ b/umap/static/umap/js/umap.forms.js @@ -1184,8 +1184,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 () {