editable-text: Allow autocomplete with wrapping

This commit is contained in:
Abe Jellinek 2024-07-09 10:31:35 -04:00 committed by Dan Stillman
parent 3e6cc03e2e
commit 38764efb5a

View file

@ -194,17 +194,17 @@
let autocompleteParams = this.autocomplete; let autocompleteParams = this.autocomplete;
let autocompleteEnabled = !this.multiline && !!autocompleteParams; let autocompleteEnabled = !this.multiline && !!autocompleteParams;
if (!this._input if (!this._input
|| (this._input.constructor.name === 'AutocompleteInput') !== autocompleteEnabled || (this._input.hasAttribute('autocomplete')) !== autocompleteEnabled
|| this._input.tagName !== (this.noWrap ? 'input' : 'textarea')) { || this._input.tagName !== (this.noWrap ? 'input' : 'textarea')) {
let input; let input;
let inputTagName = this.noWrap ? 'input' : 'textarea';
if (autocompleteEnabled) { if (autocompleteEnabled) {
input = document.createElement('input', { is: 'autocomplete-input' }); input = document.createElement(inputTagName, { is: `autocomplete-${inputTagName}` });
input.type = 'autocomplete';
} }
else { else {
input = this.noWrap ? document.createElement('input') : document.createElement('textarea'); input = document.createElement(inputTagName);
input.rows = 1;
} }
input.rows = 1;
input.classList.add('input'); input.classList.add('input');
input.toggleAttribute("no-windows-native", true); input.toggleAttribute("no-windows-native", true);
input.addEventListener('input', this._handleInput); input.addEventListener('input', this._handleInput);