File tree Expand file tree Collapse file tree
src/components/summit-dropdown Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -31,15 +31,22 @@ export default class SummitDropdown extends React.Component {
3131 }
3232
3333 handleChange ( summit ) {
34- if ( typeof summit === OBJECT_TYPEOF )
35- this . setState ( { summitValue : summit } ) ;
34+ const summitValue =
35+ summit !== null &&
36+ typeof summit === OBJECT_TYPEOF &&
37+ typeof summit . value !== UNDEFINED_TYPEOF
38+ ? summit
39+ : null ;
40+
41+ this . setState ( { summitValue } ) ;
3642 }
3743
3844 handleClick ( ev ) {
3945 ev . preventDefault ( ) ;
4046 if (
41- typeof this . state . summitValue === OBJECT_TYPEOF &&
42- typeof this . state . summitValue ?. value !== UNDEFINED_TYPEOF
47+ this . state . summitValue !== null &&
48+ typeof this . state . summitValue === OBJECT_TYPEOF &&
49+ typeof this . state . summitValue . value !== UNDEFINED_TYPEOF
4350 )
4451 this . props . onClick ( this . state . summitValue . value ) ;
4552 }
@@ -52,7 +59,10 @@ export default class SummitDropdown extends React.Component {
5259 ( a , b ) => ( a . start_date < b . start_date ? 1 : ( a . start_date > b . start_date ? - 1 : 0 ) )
5360 ) . map ( s => ( { label : s . name , value : s . id } ) ) ;
5461
55- const isDisabled = typeof this . state . summitValue !== OBJECT_TYPEOF || this . state . summitValue === null ;
62+ const isDisabled =
63+ this . state . summitValue === null ||
64+ typeof this . state . summitValue !== OBJECT_TYPEOF ||
65+ typeof this . state . summitValue . value === UNDEFINED_TYPEOF ;
5666
5767 return (
5868 < div className = { "summit-dropdown btn-group " + bigClass } >
You can’t perform that action at this time.
0 commit comments