Don't print errors when the tab is used with no autocomplete present

Fixes https://github.com/vector-im/riot-web/issues/12461

Not a release blocker because the error is caught, and is at the end of the function. Just log spam.
pull/21833/head
Travis Ralston 2020-02-25 13:13:41 -07:00
parent 1958dae519
commit 30a0d88074
1 changed files with 8 additions and 4 deletions

View File

@ -471,10 +471,14 @@ export default class BasicMessageEditor extends React.Component {
const addedLen = range.replace([partCreator.pillCandidate(range.text)]); const addedLen = range.replace([partCreator.pillCandidate(range.text)]);
return model.positionForOffset(caret.offset + addedLen, true); return model.positionForOffset(caret.offset + addedLen, true);
}); });
await model.autoComplete.onTab();
if (!model.autoComplete.hasSelection()) { // Don't try to do things with the autocomplete if there is none shown
this.setState({showVisualBell: true}); if (model.autoComplete) {
model.autoComplete.close(); await model.autoComplete.onTab();
if (!model.autoComplete.hasSelection()) {
this.setState({showVisualBell: true});
model.autoComplete.close();
}
} }
} catch (err) { } catch (err) {
console.error(err); console.error(err);