Commit 1922b566 authored by Matija Obreza's avatar Matija Obreza
Browse files

PrettyFilters value display fix, StringArrFilter handles Enter key better and adds items on blur

parent 990bf451
......@@ -87,7 +87,7 @@ function getLabelName(path, value, lookups) {
let name = value;
if (lookups && lookups[lastKey]) {
name = lookups[lastKey][value];
name = lookups[lastKey][value] || value;
}
const prettyPath: string = path
......
......@@ -70,9 +70,14 @@ class InternalStringArrField extends React.Component<IStringArrFilterInternal &
const { text } = this.state;
if (event.key === 'Enter') {
event.preventDefault();
const values = this.maybeAdd(text);
input.onChange(values);
if (text && text.length > 0) {
event.preventDefault();
const values = this.maybeAdd(text);
input.onChange(values);
} else {
// on blank, submit it
// input.onChange(values);
}
}
}
......@@ -95,7 +100,7 @@ class InternalStringArrField extends React.Component<IStringArrFilterInternal &
this.setState({ ...this.state, text: event.target.value });
}
private handleAddClick = (event) => {
private handleAddCurrent = (event) => {
const { input } = this.props;
const { text } = this.state;
......@@ -103,6 +108,7 @@ class InternalStringArrField extends React.Component<IStringArrFilterInternal &
const values = this.maybeAdd(text);
input.onChange(values);
}
public render() {
const { placeholder, label, options } = this.props;
const { text, values } = this.state;
......@@ -134,9 +140,10 @@ class InternalStringArrField extends React.Component<IStringArrFilterInternal &
onChange={ this.handleChange }
placeholder={ placeholder || '' }
onKeyPress={ this.handleKeyPres }
onBlur={ this.handleAddCurrent }
endAdornment={
<InputAdornment position="end">
<IconButton type="button" onClick={ this.handleAddClick }>
<IconButton type="button" onClick={ this.handleAddCurrent }>
<PlusOne />
</IconButton>
</InputAdornment>
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment