oa-componentbook 1.0.1-stage.417 → 1.0.1-stage.419

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.
@@ -196,6 +196,11 @@ function CustomSelect(_ref) {
196
196
  array.push(element);
197
197
  }
198
198
  };
199
+ const safeUnshift = (array, element) => {
200
+ if (!array.includes(element)) {
201
+ array.unshift(element);
202
+ }
203
+ };
199
204
 
200
205
  /**
201
206
  * Given an array of options, add all non-disabled options to the newlySelectedOptions array.
@@ -282,14 +287,15 @@ function CustomSelect(_ref) {
282
287
  }
283
288
  } else if (value === allText) {
284
289
  newlySelectedOptions.length = 0; // Emptying the array.
285
- // If fixedValue has values, push them to newlySelectedOptions
286
- if ((fixedValue === null || fixedValue === void 0 ? void 0 : fixedValue.length) > 0) {
287
- fixedValue.forEach(val => safePush(newlySelectedOptions, val));
288
- }
289
290
  } else {
290
291
  var _newlySelectedOptions2;
291
292
  newlySelectedOptions.splice((_newlySelectedOptions2 = newlySelectedOptions.indexOf) === null || _newlySelectedOptions2 === void 0 ? void 0 : _newlySelectedOptions2.call(newlySelectedOptions, value), 1);
292
293
  }
294
+
295
+ // If fixedValue has values, push them to the beginning of newlySelectedOptions
296
+ if ((fixedValue === null || fixedValue === void 0 ? void 0 : fixedValue.length) > 0) {
297
+ fixedValue.forEach(val => safeUnshift(newlySelectedOptions, val));
298
+ }
293
299
  const optionsWithoutAllText = newlySelectedOptions.filter(option => option !== allText);
294
300
 
295
301
  // Passing the data to parent, using a callback.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "oa-componentbook",
3
- "version": "1.0.1-stage.417",
3
+ "version": "1.0.1-stage.419",
4
4
  "private": false,
5
5
  "description": "Reusable components",
6
6
  "main": "build/index.js",