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
|
// not really, but we could not serialize the parts, and just change the autoCompleter
|
||||||
partCreator.setAutoCompleteCreator(autoCompleteCreator(
|
partCreator.setAutoCompleteCreator(autoCompleteCreator(
|
||||||
() => this._autocompleteRef,
|
() => this._autocompleteRef,
|
||||||
query => this.setState({query}),
|
query => new Promise(resolve => this.setState({query}, resolve)),
|
||||||
));
|
));
|
||||||
this.historyManager = new HistoryManager(partCreator);
|
this.historyManager = new HistoryManager(partCreator);
|
||||||
// initial render of model
|
// initial render of model
|
||||||
|
|
|
@ -186,13 +186,14 @@ export default class EditorModel {
|
||||||
this._mergeAdjacentParts();
|
this._mergeAdjacentParts();
|
||||||
const caretOffset = diff.at - removedOffsetDecrease + addedLen;
|
const caretOffset = diff.at - removedOffsetDecrease + addedLen;
|
||||||
let newPosition = this.positionForOffset(caretOffset, true);
|
let newPosition = this.positionForOffset(caretOffset, true);
|
||||||
this._setActivePart(newPosition, canOpenAutoComplete);
|
const acPromise = this._setActivePart(newPosition, canOpenAutoComplete);
|
||||||
if (this._transformCallback) {
|
if (this._transformCallback) {
|
||||||
const transformAddedLen = this._transform(newPosition, inputType, diff);
|
const transformAddedLen = this._transform(newPosition, inputType, diff);
|
||||||
newPosition = this.positionForOffset(caretOffset + transformAddedLen, true);
|
newPosition = this.positionForOffset(caretOffset + transformAddedLen, true);
|
||||||
}
|
}
|
||||||
this._updateInProgress = false;
|
this._updateInProgress = false;
|
||||||
this._updateCallback(newPosition, inputType, diff);
|
this._updateCallback(newPosition, inputType, diff);
|
||||||
|
return acPromise;
|
||||||
}
|
}
|
||||||
|
|
||||||
_transform(newPosition, inputType, diff) {
|
_transform(newPosition, inputType, diff) {
|
||||||
|
@ -218,13 +219,14 @@ export default class EditorModel {
|
||||||
}
|
}
|
||||||
// not _autoComplete, only there if active part is autocomplete part
|
// not _autoComplete, only there if active part is autocomplete part
|
||||||
if (this.autoComplete) {
|
if (this.autoComplete) {
|
||||||
this.autoComplete.onPartUpdate(part, pos.offset);
|
return this.autoComplete.onPartUpdate(part, pos.offset);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
this._activePartIdx = null;
|
this._activePartIdx = null;
|
||||||
this._autoComplete = null;
|
this._autoComplete = null;
|
||||||
this._autoCompletePartIdx = null;
|
this._autoCompletePartIdx = null;
|
||||||
}
|
}
|
||||||
|
return Promise.resolve();
|
||||||
}
|
}
|
||||||
|
|
||||||
_onAutoComplete = ({replacePart, caretOffset, close}) => {
|
_onAutoComplete = ({replacePart, caretOffset, close}) => {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue