diff --git a/src/editor/autocomplete.js b/src/editor/autocomplete.js index fa07ec56ff..ceaf18c444 100644 --- a/src/editor/autocomplete.js +++ b/src/editor/autocomplete.js @@ -39,8 +39,24 @@ export default class AutocompleteWrapperModel { this._updateCallback({close: true}); } - onTab() { - //forceCompletion here? + async onTab(e) { + const acComponent = this._getAutocompleterComponent(); + + if (acComponent.state.completionList.length === 0) { + // Force completions to show for the text currently entered + await acComponent.forceComplete(); + // Select the first item by moving "down" + await acComponent.onDownArrow(); + } else { + if (e.shiftKey) { + await acComponent.onUpArrow(); + } else { + await acComponent.onDownArrow(); + } + } + this._updateCallback({ + close: true, + }); } onUpArrow() { diff --git a/src/editor/parts.js b/src/editor/parts.js index ad50009d49..fbdd22d8bb 100644 --- a/src/editor/parts.js +++ b/src/editor/parts.js @@ -313,8 +313,16 @@ export class PillCandidatePart extends PlainPart { return this._autoCompleteCreator(updateCallback); } - acceptsInsertion(chr) { - return true; + acceptsInsertion(chr, i) { + if (i === 0) { + return true; + } else { + return super.acceptsInsertion(chr, i); + } + } + + merge() { + return false; } acceptsRemoval(position, chr) {