@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.
@@ -9141,17 +9141,26 @@ const multiSelectComboBoxMixin = (superclass) =>
9141
9141
  });
9142
9142
  }
9143
9143
 
9144
+ // To prevent duplicate items for the multi select options, we dedup them based on the "data-id" attribute
9145
+ // eslint-disable-next-line class-methods-use-this
9146
+ #dedupItems(items) {
9147
+ return Array.from(
9148
+ new Map(items.map((item) => [item.getAttribute('data-id'), item])).values()
9149
+ );
9150
+ }
9151
+
9144
9152
  // vaadin api is to set props on their combo box node,
9145
9153
  // in order to avoid it, we are passing the children of this component
9146
9154
  // to the items & renderer props, so it will be used as the combo box items
9147
9155
  #onChildrenChange() {
9148
9156
  const items = Array.from(this.children);
9157
+ const dedupItems = this.#dedupItems(items);
9149
9158
 
9150
9159
  // we want the data-name attribute to be accessible as an object attribute
9151
9160
  if (items.length) {
9152
9161
  this.removeAttribute('has-no-options');
9153
9162
 
9154
- items.forEach((node) => {
9163
+ dedupItems.forEach((node) => {
9155
9164
  Object.defineProperty(node, 'data-name', {
9156
9165
  value: node.getAttribute('data-name'),
9157
9166
  configurable: true,
@@ -9164,7 +9173,7 @@ const multiSelectComboBoxMixin = (superclass) =>
9164
9173
  });
9165
9174
  });
9166
9175
 
9167
- this.baseElement.items = items;
9176
+ this.baseElement.items = dedupItems;
9168
9177
 
9169
9178
  setTimeout(() => {
9170
9179
  // set timeout to ensure this runs after customValueTransformFn had the chance to be overriden