mirror of
https://github.com/element-hq/element-web
synced 2024-11-24 02:05:45 +03:00
Update src/editor/autocomplete to correctly call countCompletions and moveSelection
This commit is contained in:
parent
97d4d1b73a
commit
ed6427571e
1 changed files with 3 additions and 15 deletions
|
@ -42,31 +42,19 @@ export default class AutocompleteWrapperModel {
|
|||
async onTab(e) {
|
||||
const acComponent = this._getAutocompleterComponent();
|
||||
|
||||
if (acComponent.state.completionList.length === 0) {
|
||||
if (acComponent.countCompletions() === 0) {
|
||||
// Force completions to show for the text currently entered
|
||||
await acComponent.forceComplete();
|
||||
// Select the first item by moving "down"
|
||||
await acComponent.onDownArrow();
|
||||
await acComponent.moveSelection(+1);
|
||||
} else {
|
||||
if (e.shiftKey) {
|
||||
await acComponent.onUpArrow();
|
||||
} else {
|
||||
await acComponent.onDownArrow();
|
||||
}
|
||||
await acComponent.moveSelection(e.shiftKey ? -1 : +1);
|
||||
}
|
||||
this._updateCallback({
|
||||
close: true,
|
||||
});
|
||||
}
|
||||
|
||||
onUpArrow() {
|
||||
this._getAutocompleterComponent().onUpArrow();
|
||||
}
|
||||
|
||||
onDownArrow() {
|
||||
this._getAutocompleterComponent().onDownArrow();
|
||||
}
|
||||
|
||||
onPartUpdate(part, offset) {
|
||||
// cache the typed value and caret here
|
||||
// so we can restore it in onComponentSelectionChange when the value is undefined (meaning it should be the typed text)
|
||||
|
|
Loading…
Reference in a new issue