mirror of
https://github.com/element-hq/element-web
synced 2024-11-24 02:05:45 +03:00
return promise from updating autocomplete
so one can await if needed
This commit is contained in:
parent
0f6465a1db
commit
f76a23d5dd
2 changed files with 5 additions and 3 deletions
|
@ -304,7 +304,7 @@ export default class BasicMessageEditor extends React.Component {
|
|||
// not really, but we could not serialize the parts, and just change the autoCompleter
|
||||
partCreator.setAutoCompleteCreator(autoCompleteCreator(
|
||||
() => this._autocompleteRef,
|
||||
query => this.setState({query}),
|
||||
query => new Promise(resolve => this.setState({query}, resolve)),
|
||||
));
|
||||
this.historyManager = new HistoryManager(partCreator);
|
||||
// initial render of model
|
||||
|
|
|
@ -186,13 +186,14 @@ export default class EditorModel {
|
|||
this._mergeAdjacentParts();
|
||||
const caretOffset = diff.at - removedOffsetDecrease + addedLen;
|
||||
let newPosition = this.positionForOffset(caretOffset, true);
|
||||
this._setActivePart(newPosition, canOpenAutoComplete);
|
||||
const acPromise = this._setActivePart(newPosition, canOpenAutoComplete);
|
||||
if (this._transformCallback) {
|
||||
const transformAddedLen = this._transform(newPosition, inputType, diff);
|
||||
newPosition = this.positionForOffset(caretOffset + transformAddedLen, true);
|
||||
}
|
||||
this._updateInProgress = false;
|
||||
this._updateCallback(newPosition, inputType, diff);
|
||||
return acPromise;
|
||||
}
|
||||
|
||||
_transform(newPosition, inputType, diff) {
|
||||
|
@ -218,13 +219,14 @@ export default class EditorModel {
|
|||
}
|
||||
// not _autoComplete, only there if active part is autocomplete part
|
||||
if (this.autoComplete) {
|
||||
this.autoComplete.onPartUpdate(part, pos.offset);
|
||||
return this.autoComplete.onPartUpdate(part, pos.offset);
|
||||
}
|
||||
} else {
|
||||
this._activePartIdx = null;
|
||||
this._autoComplete = null;
|
||||
this._autoCompletePartIdx = null;
|
||||
}
|
||||
return Promise.resolve();
|
||||
}
|
||||
|
||||
_onAutoComplete = ({replacePart, caretOffset, close}) => {
|
||||
|
|
Loading…
Reference in a new issue