19504: Fix breadcrumbs height to improve text vertical centering
[arvados-workbench2.git] / src / components / autocomplete / autocomplete.tsx
index 4b19b77115b388e3613c6004013ef6501aded2b6..0044807b8a9ddb3e2abeb43a546dad5a2ada4d83 100644 (file)
@@ -2,8 +2,14 @@
 //
 // SPDX-License-Identifier: AGPL-3.0
 
-import * as React from 'react';
-import { Input as MuiInput, Chip as MuiChip, Popper as MuiPopper, Paper as MuiPaper, FormControl, InputLabel, StyleRulesCallback, withStyles, RootRef, ListItemText, ListItem, List, FormHelperText } from '@material-ui/core';
+import React from 'react';
+import {
+    Input as MuiInput,
+    Chip as MuiChip,
+    Popper as MuiPopper,
+    Paper as MuiPaper,
+    FormControl, InputLabel, StyleRulesCallback, withStyles, RootRef, ListItemText, ListItem, List, FormHelperText
+} from '@material-ui/core';
 import { PopperProps } from '@material-ui/core/Popper';
 import { WithStyles } from '@material-ui/core/styles';
 import { noop } from 'lodash';
@@ -12,6 +18,7 @@ export interface AutocompleteProps<Item, Suggestion> {
     label?: string;
     value: string;
     items: Item[];
+    disabled?: boolean;
     suggestions?: Suggestion[];
     error?: boolean;
     helperText?: string;
@@ -61,6 +68,7 @@ export class Autocomplete<Value, Suggestion> extends React.Component<Autocomplet
 
     renderInput() {
         return <Input
+            disabled={this.props.disabled}
             autoFocus={this.props.autofocus}
             inputRef={this.inputRef}
             value={this.props.value}
@@ -167,7 +175,7 @@ export class Autocomplete<Value, Suggestion> extends React.Component<Autocomplet
                 <Chip
                     label={this.renderChipValue(item)}
                     key={index}
-                    onDelete={() => onDelete ? onDelete(item, index) : undefined} />
+                    onDelete={onDelete && !this.props.disabled ? (() =>  onDelete(item, index)) : undefined} />
         );
     }