@descope/web-components-ui 1.0.260 → 1.0.261

Sign up to get free protection for your applications and to get access to all the features.
package/dist/index.esm.js CHANGED
@@ -7627,17 +7627,26 @@ const multiSelectComboBoxMixin = (superclass) =>
7627
7627
  });
7628
7628
  }
7629
7629
 
7630
+ // To prevent duplicate items for the multi select options, we dedup them based on the "data-id" attribute
7631
+ // eslint-disable-next-line class-methods-use-this
7632
+ #dedupItems(items) {
7633
+ return Array.from(
7634
+ new Map(items.map((item) => [item.getAttribute('data-id'), item])).values()
7635
+ );
7636
+ }
7637
+
7630
7638
  // vaadin api is to set props on their combo box node,
7631
7639
  // in order to avoid it, we are passing the children of this component
7632
7640
  // to the items & renderer props, so it will be used as the combo box items
7633
7641
  #onChildrenChange() {
7634
7642
  const items = Array.from(this.children);
7643
+ const dedupItems = this.#dedupItems(items);
7635
7644
 
7636
7645
  // we want the data-name attribute to be accessible as an object attribute
7637
7646
  if (items.length) {
7638
7647
  this.removeAttribute('has-no-options');
7639
7648
 
7640
- items.forEach((node) => {
7649
+ dedupItems.forEach((node) => {
7641
7650
  Object.defineProperty(node, 'data-name', {
7642
7651
  value: node.getAttribute('data-name'),
7643
7652
  configurable: true,
@@ -7650,7 +7659,7 @@ const multiSelectComboBoxMixin = (superclass) =>
7650
7659
  });
7651
7660
  });
7652
7661
 
7653
- this.baseElement.items = items;
7662
+ this.baseElement.items = dedupItems;
7654
7663
 
7655
7664
  setTimeout(() => {
7656
7665
  // set timeout to ensure this runs after customValueTransformFn had the chance to be overriden