From eb0e7b72c71f77ed3688350ebe6e5a7e0239dbd4 Mon Sep 17 00:00:00 2001 From: Mads Rasmussen Date: Fri, 20 Jan 2023 13:02:20 +0100 Subject: [PATCH] add focus to new element --- .../property-editor-ui-multiple-text-string.element.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/Umbraco.Web.UI.Client/src/backoffice/shared/property-editors/uis/multiple-text-string/property-editor-ui-multiple-text-string.element.ts b/src/Umbraco.Web.UI.Client/src/backoffice/shared/property-editors/uis/multiple-text-string/property-editor-ui-multiple-text-string.element.ts index ed54c8c915..06f01497f0 100644 --- a/src/Umbraco.Web.UI.Client/src/backoffice/shared/property-editors/uis/multiple-text-string/property-editor-ui-multiple-text-string.element.ts +++ b/src/Umbraco.Web.UI.Client/src/backoffice/shared/property-editors/uis/multiple-text-string/property-editor-ui-multiple-text-string.element.ts @@ -67,6 +67,7 @@ export class UmbPropertyEditorUIMultipleTextStringElement extends LitElement { private _onAdd() { this._value = [...this._value, { value: '' }]; this.dispatchEvent(new UmbPropertyValueChangeEvent()); + this._focusNewItem(); } private _onInput(event: UUIInputEvent) { @@ -77,6 +78,13 @@ export class UmbPropertyEditorUIMultipleTextStringElement extends LitElement { this.dispatchEvent(new UmbPropertyValueChangeEvent()); } + private async _focusNewItem() { + await this.updateComplete; + const inputs = this.shadowRoot?.querySelectorAll('uui-input') as NodeListOf; + const lastInput = inputs[inputs.length - 1]; + lastInput.focus(); + } + render() { return html` ${this._renderItems()}