@descope/web-components-ui 1.0.256 → 1.0.257

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -9039,7 +9039,7 @@ const multiSelectComboBoxMixin = (superclass) =>
9039
9039
  }
9040
9040
  }
9041
9041
 
9042
- get allowCustomValue() {
9042
+ get allowCustomValues() {
9043
9043
  return this.getAttribute('allow-custom-value') === 'true';
9044
9044
  }
9045
9045
 
@@ -9178,7 +9178,7 @@ const multiSelectComboBoxMixin = (superclass) =>
9178
9178
  }
9179
9179
 
9180
9180
  #handleCustomValues() {
9181
- if (this.allowCustomValue) {
9181
+ if (this.allowCustomValues) {
9182
9182
  this.baseElement.addEventListener('custom-value-set', (e) => {
9183
9183
  const newItemHtml = this.#renderItem({
9184
9184
  label: e.detail,
@@ -9286,6 +9286,33 @@ const multiSelectComboBoxMixin = (superclass) =>
9286
9286
  const selectedChildren = this.baseElement.items?.filter((item) =>
9287
9287
  vals.includes(item['data-id'])
9288
9288
  );
9289
+
9290
+ // If the component allows custom values, we need to add the values that are not present in the children
9291
+ if (this.allowCustomValues) {
9292
+ const existingValues =
9293
+ selectedChildren?.map((child) => child.getAttribute('data-id')) || [];
9294
+ const missingValues = vals.filter((val) => !existingValues.includes(val));
9295
+
9296
+ if (missingValues.length) {
9297
+ const newItemsHtml = missingValues.reduce((acc, val) => {
9298
+ const newItemHtml = this.#renderItem({
9299
+ label: val,
9300
+ displayName: val,
9301
+ value: val,
9302
+ });
9303
+ return acc + newItemHtml;
9304
+ }, '');
9305
+ this.innerHTML += newItemsHtml;
9306
+
9307
+ // The value needs to be set with a timeout because it needs to execute after
9308
+ // the custom values are added to the items by the children change observer
9309
+ setTimeout(() => {
9310
+ this.value = vals;
9311
+ }, 0);
9312
+ return;
9313
+ }
9314
+ }
9315
+
9289
9316
  const newSelectedValues =
9290
9317
  selectedChildren?.map((child) => child.getAttribute('data-id')) || [];
9291
9318
  if (!compareArraysUnordered(this.#value, newSelectedValues)) {