@@ -2,7 +2,7 @@ import { Component, createElement } from "react";
22import * as initializeReactFastclick from "react-fastclick" ;
33import { hot } from "react-hot-loader" ;
44
5- import { AttributeType , DropdownReferenceProps , ReferenceOption , parseStyle , validateProps } from "../../SharedResources/utils/ContainerUtils" ;
5+ import { AttributeType , DropdownProps , ReferenceOption , parseStyle , validateProps } from "../../SharedResources/utils/ContainerUtils" ;
66import { FetchDataOptions , fetchData } from "../../SharedResources/utils/Data" ;
77import { DropdownReference } from "./DropdownReference" ;
88
@@ -15,7 +15,7 @@ interface WrapperProps {
1515 friendlyId : string ;
1616}
1717
18- export interface ContainerProps extends WrapperProps , DropdownReferenceProps {
18+ export interface ContainerProps extends WrapperProps , DropdownProps {
1919 attribute : string ;
2020 entityPath : string ;
2121 entityConstraint : string ;
@@ -33,7 +33,7 @@ export interface ContainerProps extends WrapperProps, DropdownReferenceProps {
3333export interface ContainerState {
3434 isClearable : boolean ;
3535 options : ReferenceOption [ ] ;
36- selectedObject : any ;
36+ selectedObject : ReferenceOption ;
3737}
3838
3939class DropdownReferenceContainer extends Component < ContainerProps , ContainerState > {
@@ -143,7 +143,7 @@ class DropdownReferenceContainer extends Component<ContainerProps, ContainerStat
143143 this . subscriptionHandles . push ( window . mx . data . subscribe ( {
144144 entity : this . props . entityPath . split ( "/" ) [ 1 ] ,
145145 callback : ( ) => {
146- this . setState ( { selectedObject : null } ) ;
146+ this . setState ( { selectedObject : { } } ) ;
147147 this . getSelectedValue ( this . props ) ;
148148 this . retrieveOptions ( this . props ) ;
149149 }
@@ -163,15 +163,15 @@ class DropdownReferenceContainer extends Component<ContainerProps, ContainerStat
163163 } else {
164164 this . props . mxObject . set ( this . association , selection . value ) ;
165165 if ( ! this . state . selectedObject || ( this . state . selectedObject . value !== selection . value ) ) {
166- this . executeOnChangeEvent ( ) ;
166+ this . executeOnChangeAction ( ) ;
167167 }
168168 }
169169 }
170170
171- this . setState ( { selectedObject : selection ? selection : null } ) ;
171+ this . setState ( { selectedObject : selection ? selection : { } } ) ;
172172 }
173173
174- private executeOnChangeEvent ( ) {
174+ private executeOnChangeAction ( ) {
175175 const { mxform, mxObject, onChangeEvent, onChangeMicroflow, onChangeNanoflow } = this . props ;
176176 const context = new mendix . lib . MxContext ( ) ;
177177
@@ -232,10 +232,10 @@ class DropdownReferenceContainer extends Component<ContainerProps, ContainerStat
232232 this . setState ( { options } ) ;
233233 }
234234
235- private setAsyncOptions = ( input : string ) : Promise < { options : ReferenceOption [ ] } > => {
235+ private setAsyncOptions = ( input ? : string ) : Promise < { options : ReferenceOption [ ] } > => {
236236 if ( this . props . mxObject ) {
237237 this . props . mxObject . set ( this . props . searchAttribute , input ) ;
238- if ( input . length >= this . props . minimumCharacter ) {
238+ if ( input && input . length >= this . props . minimumCharacter ) {
239239 return this . retrieveOptions ( this . props , input )
240240 . then ( ( ) => Promise . resolve ( { options : this . state . options } ) ) ;
241241 } else {
0 commit comments