From 76bf33b24896d2efe4c4c148a136d6b16e8d1b36 Mon Sep 17 00:00:00 2001 From: Alexander Ebert Date: Thu, 26 May 2022 13:45:20 +0200 Subject: [PATCH] Show a text cursor while the item list accepts items --- ts/WoltLabSuite/Core/Ui/ItemList.ts | 3 +++ wcfsetup/install/files/js/WoltLabSuite/Core/Ui/ItemList.js | 3 +++ wcfsetup/install/files/style/ui/itemListInput.scss | 4 ++++ 3 files changed, 10 insertions(+) diff --git a/ts/WoltLabSuite/Core/Ui/ItemList.ts b/ts/WoltLabSuite/Core/Ui/ItemList.ts index a9990cd35e..6807bc1609 100644 --- a/ts/WoltLabSuite/Core/Ui/ItemList.ts +++ b/ts/WoltLabSuite/Core/Ui/ItemList.ts @@ -26,6 +26,7 @@ function createUI(element: ItemListInputElement, options: ItemListOptions): UiDa const list = document.createElement("ol"); list.className = "inputItemList" + (element.disabled ? " disabled" : ""); + list.dataset.acceptsNewItems = "true"; list.dataset.elementId = element.id; list.addEventListener("click", (event) => { if (event.target === list) { @@ -123,9 +124,11 @@ function handleLimit(elementId: string): void { if (acceptsNewItems(elementId)) { DomUtil.show(data.element); DomUtil.hide(data.limitReached); + data.list.dataset.acceptsNewItems = "true"; } else { DomUtil.hide(data.element); DomUtil.show(data.limitReached); + data.list.dataset.acceptsNewItems = "false"; } } diff --git a/wcfsetup/install/files/js/WoltLabSuite/Core/Ui/ItemList.js b/wcfsetup/install/files/js/WoltLabSuite/Core/Ui/ItemList.js index 28a7853c56..0ead64c283 100644 --- a/wcfsetup/install/files/js/WoltLabSuite/Core/Ui/ItemList.js +++ b/wcfsetup/install/files/js/WoltLabSuite/Core/Ui/ItemList.js @@ -25,6 +25,7 @@ define(["require", "exports", "tslib", "../Core", "../Dom/Traverse", "../Languag const parentElement = element.parentElement; const list = document.createElement("ol"); list.className = "inputItemList" + (element.disabled ? " disabled" : ""); + list.dataset.acceptsNewItems = "true"; list.dataset.elementId = element.id; list.addEventListener("click", (event) => { if (event.target === list) { @@ -109,10 +110,12 @@ define(["require", "exports", "tslib", "../Core", "../Dom/Traverse", "../Languag if (acceptsNewItems(elementId)) { Util_1.default.show(data.element); Util_1.default.hide(data.limitReached); + data.list.dataset.acceptsNewItems = "true"; } else { Util_1.default.hide(data.element); Util_1.default.show(data.limitReached); + data.list.dataset.acceptsNewItems = "false"; } } /** diff --git a/wcfsetup/install/files/style/ui/itemListInput.scss b/wcfsetup/install/files/style/ui/itemListInput.scss index 02902a8f81..3147587987 100644 --- a/wcfsetup/install/files/style/ui/itemListInput.scss +++ b/wcfsetup/install/files/style/ui/itemListInput.scss @@ -6,6 +6,10 @@ padding-bottom: 0; padding-top: 5px; + &[data-accepts-new-items="true"] { + cursor: text; + } + > .item, > .input { flex: 0 0 auto; -- 2.20.1