From e952599f72ee22a10b78b9cd10e4091ae00f051d Mon Sep 17 00:00:00 2001 From: Stefanos Natsis Date: Thu, 23 May 2024 12:27:11 +0300 Subject: [PATCH] Fix not null value relation (#3446) --- .../editors/MMFormValueRelationEditor.qml | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/app/qml/form/editors/MMFormValueRelationEditor.qml b/app/qml/form/editors/MMFormValueRelationEditor.qml index d43c5a950..59f7837a8 100644 --- a/app/qml/form/editors/MMFormValueRelationEditor.qml +++ b/app/qml/form/editors/MMFormValueRelationEditor.qml @@ -74,15 +74,6 @@ MMFormComboboxBaseEditor { valueRole: "FeatureId" textRole: "FeatureTitle" - selected: { - if ( internal.allowMultivalue ) { - return vrModel.convertFromQgisType( root._fieldValue, MM.FeaturesModel.FeatureId ) - } - else { - return [root._fieldValue] - } - } - list.model: MM.ValueRelationFeaturesModel { id: vrDropdownModel @@ -120,7 +111,16 @@ MMFormComboboxBaseEditor { close() } - Component.onCompleted: open() + Component.onCompleted: { + // We want to set the initial value of 'selected' property but not bind it so we avoid a binding loop + if ( internal.allowMultivalue ) { + selected = vrModel.convertFromQgisType( root._fieldValue, MM.FeaturesModel.FeatureId ) + } + else { + selected = [root._fieldValue] + } + open() + } } }