Pārlūkot izejas kodu

handle nullish values in SelectControl

Alexander Rose 5 gadi atpakaļ
vecāks
revīzija
928a1df525
1 mainītis faili ar 3 papildinājumiem un 3 dzēšanām
  1. 3 3
      src/mol-plugin-ui/controls/parameters.tsx

+ 3 - 3
src/mol-plugin-ui/controls/parameters.tsx

@@ -349,12 +349,12 @@ export class SelectControl extends React.PureComponent<ParamProps<PD.Select<stri
 
     renderControl() {
         const items = this.items(this.props.param);
-        const current = this.props.value ? ActionMenu.findCurrent(items, this.props.value) : void 0;
+        const current = this.props.value !== undefined ? ActionMenu.findCurrent(items, this.props.value) : void 0;
         const label = current
             ? current.label
             : typeof this.props.value === 'undefined'
-            ? `${ActionMenu.getFirstItem(items)?.label || ''} [Default]`
-            : `[Invalid] ${this.props.value}`
+                ? `${ActionMenu.getFirstItem(items)?.label || ''} [Default]`
+                : `[Invalid] ${this.props.value}`
         return <ToggleButton disabled={this.props.isDisabled} style={{ textAlign: 'left', overflow: 'hidden', textOverflow: 'ellipsis' }}
             label={label} title={label as string} toggle={this.toggle} isSelected={this.state.showOptions} />;
     }