From 6e2a08cae8943e959194bb059b49cb797df04cef Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Wed, 21 Aug 2024 10:22:13 +0200 Subject: [PATCH] Resolve multiple entries not being saved in collectiontype --- .../Resources/public/module/collection/index.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/Bundle/ChillMainBundle/Resources/public/module/collection/index.ts b/src/Bundle/ChillMainBundle/Resources/public/module/collection/index.ts index b48324786..875e99fad 100644 --- a/src/Bundle/ChillMainBundle/Resources/public/module/collection/index.ts +++ b/src/Bundle/ChillMainBundle/Resources/public/module/collection/index.ts @@ -53,10 +53,13 @@ export const handleAdd = (button: any): void => { let empty_explain: HTMLLIElement | null = collection.querySelector('li[data-collection-empty-explain]'), entry = document.createElement('li'), - counter = collection.childNodes.length + 1, - content = prototype.replace(new RegExp('__name__', 'g'), counter.toString()), + counter = collection.querySelectorAll('li.entry').length, // Updated counter logic + content = prototype.replace(/__name__/g, counter.toString()), event = new CustomEvent('collection-add-entry', {detail: new CollectionEventPayload(collection, entry)}); + console.log(counter) + console.log(content) + entry.innerHTML = content; entry.classList.add('entry');