Set default engine and remain last engine on form settings
This commit is contained in:
parent
3686bbbabf
commit
37cd9d2f91
1 changed files with 6 additions and 1 deletions
|
@ -54,6 +54,7 @@ class SearchForm extends React.Component<Props> {
|
||||||
</div>;
|
</div>;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// eslint-disable-next-line max-statements
|
||||||
bindValue(e: any) {
|
bindValue(e: any) {
|
||||||
let value = this.props.value.toJSON();
|
let value = this.props.value.toJSON();
|
||||||
let name = e.target.name;
|
let name = e.target.name;
|
||||||
|
@ -72,8 +73,12 @@ class SearchForm extends React.Component<Props> {
|
||||||
next.default = value.engines[index][0];
|
next.default = value.engines[index][0];
|
||||||
} else if (name === 'add') {
|
} else if (name === 'add') {
|
||||||
next.engines.push(['', '']);
|
next.engines.push(['', '']);
|
||||||
} else if (name === 'delete') {
|
} else if (name === 'delete' && value.engines.length > 1) {
|
||||||
next.engines.splice(index, 1);
|
next.engines.splice(index, 1);
|
||||||
|
if (value.engines[index][0] === value.default) {
|
||||||
|
let nextIndex = Math.min(index, next.engines.length - 1);
|
||||||
|
next.default = next.engines[nextIndex][0];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this.props.onChange(FormSearch.valueOf(next));
|
this.props.onChange(FormSearch.valueOf(next));
|
||||||
|
|
Reference in a new issue