@@ -55,17 +55,17 @@ export class DatabaseSingleSelectionSelector<T extends string | Big, R extends E
5555 valueSourceAttribute
5656 } = extractDatabaseProps ( props ) ;
5757
58+ if ( ds . status === "loading" && ( ! lazyLoading || ds . limit !== Infinity ) ) {
59+ return ;
60+ }
61+
5862 this . _attr = targetAttribute as R ;
5963 this . readOnly = getReadonly ( targetAttribute , props . customEditability , props . customEditabilityExpression ) ;
6064 this . lazyLoader . updateProps ( ds ) ;
6165 this . lazyLoader . setLimit (
6266 this . lazyLoader . getLimit ( ds . limit , this . readOnly , targetAttribute ?. status ?? ds . status , lazyLoading )
6367 ) ;
6468
65- if ( ds . status === "loading" ) {
66- return ;
67- }
68-
6969 this . caption . updateProps ( {
7070 emptyOptionText : emptyOption ,
7171 formattingAttributeOrExpression : captionProvider ,
@@ -101,9 +101,18 @@ export class DatabaseSingleSelectionSelector<T extends string | Big, R extends E
101101 } ) ;
102102 if ( obj ) {
103103 this . currentId = obj ;
104+ } else {
105+ // NOTE: should not hit this scope normally
106+ // if the value is not in the options list, but there is a value from attribute
107+ // there is probably a mismatch between the value and the datasource
108+ // logical next step is to try to reload the attribute value
109+ // this.options.loadSelectedValue(targetAttribute.value?.toString(), valueSourceAttribute?.id);
104110 }
105111 } else {
106- this . options . loadSelectedValue ( targetAttribute . value ?. toString ( ) ) ;
112+ // should hit on initial condition whereas:
113+ // no options are loaded yet : (allOptions.length > 0)
114+ // but there is a value from target attribute : (!this.currentId)
115+ this . options . loadSelectedValue ( targetAttribute . value ?. toString ( ) , valueSourceAttribute ?. id ) ;
107116 }
108117 } else if ( ! targetAttribute . value && this . currentId ) {
109118 this . currentId = null ;
0 commit comments