diff options
Diffstat (limited to 'src/settings/components')
-rw-r--r-- | src/settings/components/form/SearchForm.tsx | 7 | ||||
-rw-r--r-- | src/settings/components/index.tsx | 2 |
2 files changed, 8 insertions, 1 deletions
diff --git a/src/settings/components/form/SearchForm.tsx b/src/settings/components/form/SearchForm.tsx index cf78a69..6ba6cfb 100644 --- a/src/settings/components/form/SearchForm.tsx +++ b/src/settings/components/form/SearchForm.tsx @@ -54,6 +54,7 @@ class SearchForm extends React.Component<Props> { </div>; } + // eslint-disable-next-line max-statements bindValue(e: any) { let value = this.props.value.toJSON(); let name = e.target.name; @@ -72,8 +73,12 @@ class SearchForm extends React.Component<Props> { next.default = value.engines[index][0]; } else if (name === 'add') { next.engines.push(['', '']); - } else if (name === 'delete') { + } else if (name === 'delete' && value.engines.length > 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)); diff --git a/src/settings/components/index.tsx b/src/settings/components/index.tsx index b4a0866..eeac2cf 100644 --- a/src/settings/components/index.tsx +++ b/src/settings/components/index.tsx @@ -175,6 +175,7 @@ class SettingsComponent extends React.Component<Props> { if (from === 'form' && value === 'json') { this.props.dispatch(settingActions.switchToJson( this.props.form as FormSettings)); + this.save(); } else if (from === 'json' && value === 'form') { let b = window.confirm(DO_YOU_WANT_TO_CONTINUE); if (!b) { @@ -183,6 +184,7 @@ class SettingsComponent extends React.Component<Props> { } this.props.dispatch( settingActions.switchToForm(this.props.json as JSONSettings)); + this.save(); } } |