Merge branch 'master' into 14603-add-controlled-vocabulary-to-advanced-search
authorMichal Klobukowski <michal.klobukowski@contractors.roche.com>
Mon, 17 Dec 2018 16:56:55 +0000 (17:56 +0100)
committerMichal Klobukowski <michal.klobukowski@contractors.roche.com>
Mon, 17 Dec 2018 16:56:55 +0000 (17:56 +0100)
refs #14603

Arvados-DCO-1.1-Signed-off-by: Michal Klobukowski <michal.klobukowski@contractors.roche.com>

1  2 
src/components/autocomplete/autocomplete.tsx

index 57881f1ac3cd6dab7bd993da7c5d9130aa602f92,b250c7b8ecd43bfc89171e4a9de373bf0cd22ffa..52918c34ab47ee68c009cff6bd5bfdb42b80598b
@@@ -15,6 -15,7 +15,7 @@@ export interface AutocompleteProps<Item
      suggestions?: Suggestion[];
      error?: boolean;
      helperText?: string;
+     autofocus?: boolean;
      onChange: (event: React.ChangeEvent<HTMLInputElement>) => void;
      onBlur?: (event: React.FocusEvent<HTMLInputElement>) => void;
      onFocus?: (event: React.FocusEvent<HTMLInputElement>) => void;
@@@ -29,6 -30,7 +30,7 @@@ export interface AutocompleteState 
      suggestionsOpen: boolean;
      selectedSuggestionIndex: number;
  }
  export class Autocomplete<Value, Suggestion> extends React.Component<AutocompleteProps<Value, Suggestion>, AutocompleteState> {
  
      state = {
@@@ -59,6 -61,7 +61,7 @@@
  
      renderInput() {
          return <Input
+             autoFocus={this.props.autofocus}
              inputRef={this.inputRef}
              value={this.props.value}
              startAdornment={this.renderChips()}
  
      renderChips() {
          const { items, onDelete } = this.props;
 +
 +        /**
 +         * If input startAdornment prop is not undefined, input's label will stay above the input.
 +         * If there is not items, we want the label to go back to placeholder position.
 +         */
 +        if (items.length === 0) {
 +            return;
 +        }
 +
          return items.map(
              (item, index) =>
                  <Chip