From 0c35e31d4c1ec6ff3c780da2dc5cd4fff8c4ce27 Mon Sep 17 00:00:00 2001 From: mirivlad Date: Mon, 30 Mar 2026 14:30:41 +0800 Subject: [PATCH] =?UTF-8?q?Fix:=20=D0=98=D1=81=D0=BF=D1=80=D0=B0=D0=B2?= =?UTF-8?q?=D0=BB=D0=B5=D0=BD=D0=BE=20=D0=B4=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB?= =?UTF-8?q?=D0=B5=D0=BD=D0=B8=D0=B5=20=D1=81=D1=83=D1=89=D0=B5=D1=81=D1=82?= =?UTF-8?q?=D0=B2=D1=83=D1=8E=D1=89=D0=B8=D1=85=20=D1=82=D0=B5=D0=B3=D0=BE?= =?UTF-8?q?=D0=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ✅ Создаём бейджи напрямую без addTag() ✅ selectedTags.add() перед созданием бейджа Co-authored-by: Qwen-Coder --- .../views/components/tags-input.blade.php | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/resources/views/components/tags-input.blade.php b/resources/views/components/tags-input.blade.php index 74b3a54..526dbcb 100644 --- a/resources/views/components/tags-input.blade.php +++ b/resources/views/components/tags-input.blade.php @@ -125,8 +125,12 @@ document.addEventListener('DOMContentLoaded', function() { // Добавление тега function addTag(id, data) { console.log('[TagsInput] addTag called with id:', id, 'data:', data); - if (!data || selectedTags.has(String(id))) { - console.log('[TagsInput] Skipping tag (no data or already selected)'); + if (!data) { + console.log('[TagsInput] Skipping tag (no data)'); + return; + } + if (selectedTags.has(String(id))) { + console.log('[TagsInput] Tag already selected, skipping'); return; } @@ -195,7 +199,16 @@ document.addEventListener('DOMContentLoaded', function() { items.forEach(item => { console.log('[TagsInput] Adding existing option:', item); select.addOption(item); - addTag(item.id, item); + // Добавляем в selectedTags и создаём бейдж напрямую + selectedTags.add(String(item.id)); + updateHiddenInput(); + + const tag = document.createElement('div'); + tag.className = 'tag-badge'; + tag.dataset.id = item.id; + tag.innerHTML = `${escapeHtml(item.text)}×`; + tagsContainer.appendChild(tag); + console.log('[TagsInput] Tag appended:', tag); }); }) .catch(err => {