magneto365.ui 2.65.3 → 2.65.4

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.
package/dist/esm/index.js CHANGED
@@ -7761,8 +7761,25 @@ var useSelect2 = function (_a) {
7761
7761
  }
7762
7762
  }, [searchValue, setTerm]);
7763
7763
  useEffect(function () {
7764
- if (!currentFields || !currentFields.length) {
7765
- setValueSelected([]);
7764
+ if (!currentFields) {
7765
+ if (valueSelected.length !== 0) {
7766
+ setValueSelected([]);
7767
+ }
7768
+ return;
7769
+ }
7770
+ if (!Array.isArray(currentFields)) {
7771
+ if ('id' in currentFields && 'name' in currentFields) {
7772
+ var newValue = [currentFields];
7773
+ if (JSON.stringify(valueSelected) !== JSON.stringify(newValue)) {
7774
+ setValueSelected(newValue);
7775
+ }
7776
+ }
7777
+ return;
7778
+ }
7779
+ if (currentFields.length === 0) {
7780
+ if (valueSelected.length !== 0) {
7781
+ setValueSelected([]);
7782
+ }
7766
7783
  return;
7767
7784
  }
7768
7785
  setValueSelected(function (prev) {
@@ -7771,7 +7788,7 @@ var useSelect2 = function (_a) {
7771
7788
  }
7772
7789
  return currentFields;
7773
7790
  });
7774
- }, [currentFields]);
7791
+ }, [currentFields, valueSelected]);
7775
7792
  useEffect(function () {
7776
7793
  if (limitSelections && valueSelected.length >= limitSelections) {
7777
7794
  setDisableList(true);