From a95f6cc100e9ace7d03b40323a5377f04f8396d3 Mon Sep 17 00:00:00 2001 From: MaxOvs Date: Tue, 18 Oct 2022 14:13:14 +0300 Subject: [PATCH] Fix bug in Url list --- src/cg-dropdown.js | 4 ++-- src/components/create-element.js | 8 +++++--- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/cg-dropdown.js b/src/cg-dropdown.js index ade425b..a43ab33 100644 --- a/src/cg-dropdown.js +++ b/src/cg-dropdown.js @@ -368,8 +368,8 @@ export class DropDown { } } else { if (multiselectTag) { - const tagItem = document.getElementById(`tag-${index}`); - // TODO: bug error! in url + const tagItem = document.getElementById(`tag-${index}-${item.id}`); + ul.removeChild(tagItem); } this.#indexes.splice(checkIndex, 1); diff --git a/src/components/create-element.js b/src/components/create-element.js index 9394c49..da418c3 100644 --- a/src/components/create-element.js +++ b/src/components/create-element.js @@ -4,7 +4,6 @@ import { customStylesFormat } from './utils'; export function createBreadcrumb(data, title, index, id) { const { element, option, indexes, selectedItems } = data; const { placeholder, styles } = option; - const { chips } = styles; const selected = element.querySelector('.selected'); const liChip = document.createElement('li'); @@ -16,7 +15,7 @@ export function createBreadcrumb(data, title, index, id) { svgIcon.setAttribute('viewBox', '0 0 10 10'); path1.setAttribute('d', 'M3,7 L7,3'); path2.setAttribute('d', 'M3,3 L7,7'); - liChip.setAttribute('id', `tag-${index}`); + liChip.setAttribute('id', `tag-${index}-${id}`); svgIcon.classList.add('svg-icon'); @@ -25,7 +24,10 @@ export function createBreadcrumb(data, title, index, id) { liChip.appendChild(textNode); liChip.appendChild(svgIcon); - customStylesFormat(chips, liChip); + if (styles) { + const { chips } = styles; + customStylesFormat(chips, liChip); + } svgIcon.addEventListener('click', (event) => { event.stopPropagation();