values: Value[];
getLabel?: (value: Value) => string;
onChange: (value: Value[]) => void;
+ handleFocus?: (e: any) => void;
+ handleBlur?: (e: any) => void;
+ chipsClassName?: string;
createNewValue: (value: string) => Value;
inputComponent?: React.ComponentType<InputProps>;
inputProps?: InputProps;
this.setState({ text: event.target.value });
}
- handleKeyPress = ({ key }: React.KeyboardEvent<HTMLInputElement>) => {
- if (key === 'Enter') {
+ handleKeyPress = (e: React.KeyboardEvent<HTMLInputElement>) => {
+ if (e.key === 'Enter') {
this.createNewValue();
- } else if (key === 'Backspace') {
+ e.preventDefault();
+ } else if (e.key === 'Backspace') {
this.deleteLastValue();
}
}
renderChips() {
const { classes, ...props } = this.props;
- return <div className={classes.chips}>
+ return <div className={[classes.chips, this.props.chipsClassName].join(' ')}>
<Chips
{...props}
clickable={!props.disabled}
onChange={this.setText}
disabled={this.props.disabled}
onKeyDown={this.handleKeyPress}
+ onFocus={this.props.handleFocus}
+ onBlur={this.props.handleBlur}
inputProps={{
...(InputProps && InputProps.inputProps),
className: classes.input,