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;
suggestionsOpen: boolean;
selectedSuggestionIndex: number;
}
+
export class Autocomplete<Value, Suggestion> extends React.Component<AutocompleteProps<Value, Suggestion>, AutocompleteState> {
state = {
renderInput() {
return <Input
+ autoFocus={this.props.autofocus}
inputRef={this.inputRef}
value={this.props.value}
startAdornment={this.renderChips()}
if (event.key === 'Enter') {
if (this.isSuggestionBoxOpen() && selectedSuggestionIndex < suggestions.length) {
// prevent form submissions when selecting a suggestion
- event.preventDefault();
+ event.preventDefault();
onSelect(suggestions[selectedSuggestionIndex]);
} else if (this.props.value.length > 0) {
onCreate();