lisichatbot 2.0.3 → 2.0.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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/index.js +21 -2
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lisichatbot",
3
- "version": "2.0.3",
3
+ "version": "2.0.4",
4
4
  "type": "module",
5
5
  "main": "./src/index.js",
6
6
  "exports": {
package/src/index.js CHANGED
@@ -1068,18 +1068,37 @@ function renderCustomSelectOptions(options, field, customConfig) {
1068
1068
  }
1069
1069
  } else {
1070
1070
  // Regular option selected
1071
- const selectedOption = options.find(o =>
1071
+ // Try to find the matching option by value
1072
+ let selectedOption = options.find(o =>
1072
1073
  JSON.stringify(o.value !== undefined ? o.value : o) === JSON.stringify(existingData)
1073
1074
  );
1074
1075
 
1076
+ // ✅ If not found and existingData is a primitive, try direct match
1077
+ if (!selectedOption && (typeof existingData === 'string' || typeof existingData === 'number')) {
1078
+ selectedOption = options.find(o => o === existingData || o.value === existingData);
1079
+ }
1080
+
1081
+ let displayName;
1082
+ if (selectedOption) {
1083
+ displayName = selectedOption.name || selectedOption;
1084
+ } else {
1085
+ // Fallback to existingData if option not found
1086
+ displayName = existingData;
1087
+ console.warn(` ⚠️ Could not find matching option for value:`, existingData);
1088
+ }
1089
+
1075
1090
  chatState.currentSelection = {
1076
1091
  field,
1077
1092
  value: existingData,
1078
- name: selectedOption ? (selectedOption.name || selectedOption) : existingData
1093
+ name: displayName
1079
1094
  };
1080
1095
 
1081
1096
  enableNextButton();
1082
1097
  console.log(` ✅ Pre-selected option found - Next button enabled`);
1098
+ console.log(` Field: "${field}"`);
1099
+ console.log(` Value:`, existingData);
1100
+ console.log(` Display name: "${displayName}"`);
1101
+ console.log(` 📝 Set chatState.currentSelection:`, chatState.currentSelection);
1083
1102
  }
1084
1103
  }
1085
1104
  }