lisichatbot 1.4.4 → 1.4.5
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/package.json +1 -1
- package/src/index.js +32 -21
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -610,7 +610,7 @@ function renderOptions(options, field, isSingleSelect = true) {
|
|
|
610
610
|
el.onclick = (e) => {
|
|
611
611
|
e.stopPropagation();
|
|
612
612
|
e.preventDefault();
|
|
613
|
-
handleOptionClick(el, field, isSingleSelect);
|
|
613
|
+
handleOptionClick(el, field, isSingleSelect, options); // ✅ Pass options
|
|
614
614
|
};
|
|
615
615
|
});
|
|
616
616
|
|
|
@@ -739,7 +739,7 @@ function renderColorOptions(options, field) {
|
|
|
739
739
|
el.onclick = (e) => {
|
|
740
740
|
e.stopPropagation();
|
|
741
741
|
e.preventDefault();
|
|
742
|
-
handleOptionClick(el, field, false);
|
|
742
|
+
handleOptionClick(el, field, false, options); // ✅ Pass options
|
|
743
743
|
};
|
|
744
744
|
});
|
|
745
745
|
|
|
@@ -1555,7 +1555,7 @@ function renderTextInput(field, inputType = 'text', inputConfig = {}) {
|
|
|
1555
1555
|
// OPTION CLICK HANDLER USING CUSTOM ATTRIBUTES
|
|
1556
1556
|
// =============================================================================
|
|
1557
1557
|
|
|
1558
|
-
function handleOptionClick(element, field, isSingleSelect) {
|
|
1558
|
+
function handleOptionClick(element, field, isSingleSelect, options) {
|
|
1559
1559
|
const now = Date.now();
|
|
1560
1560
|
const lastClick = element.getAttribute('data-last-click');
|
|
1561
1561
|
if (lastClick && (now - parseInt(lastClick)) < 300) {
|
|
@@ -1705,24 +1705,35 @@ function handleOptionClick(element, field, isSingleSelect) {
|
|
|
1705
1705
|
console.log(` chatState.data.${field}:`, chatState.data[field]);
|
|
1706
1706
|
}
|
|
1707
1707
|
|
|
1708
|
-
|
|
1709
|
-
|
|
1710
|
-
|
|
1711
|
-
|
|
1712
|
-
|
|
1713
|
-
|
|
1714
|
-
|
|
1715
|
-
|
|
1716
|
-
|
|
1717
|
-
|
|
1718
|
-
|
|
1719
|
-
|
|
1720
|
-
|
|
1721
|
-
|
|
1722
|
-
|
|
1723
|
-
|
|
1724
|
-
|
|
1725
|
-
|
|
1708
|
+
// ✅ FIX: Build currentSelection from actual data array, not DOM elements
|
|
1709
|
+
// The DOM might have duplicate/old elements that still have cf-checked class
|
|
1710
|
+
if (!chatState.data[field] || chatState.data[field].length === 0) {
|
|
1711
|
+
// No selections
|
|
1712
|
+
chatState.currentSelection = null;
|
|
1713
|
+
console.log(`📊 No selections - currentSelection set to null`);
|
|
1714
|
+
} else {
|
|
1715
|
+
// Build name from actual data array by finding matching options
|
|
1716
|
+
const selectedNames = chatState.data[field].map(val => {
|
|
1717
|
+
// Find the option config that matches this value
|
|
1718
|
+
const matchingOption = options.find(opt => {
|
|
1719
|
+
const optValue = opt.value !== undefined ? opt.value : opt;
|
|
1720
|
+
return JSON.stringify(optValue) === JSON.stringify(val);
|
|
1721
|
+
});
|
|
1722
|
+
return matchingOption ? (matchingOption.name || matchingOption) : val;
|
|
1723
|
+
}).join(', ');
|
|
1724
|
+
|
|
1725
|
+
chatState.currentSelection = {
|
|
1726
|
+
field,
|
|
1727
|
+
value: chatState.data[field],
|
|
1728
|
+
name: selectedNames || 'None selected'
|
|
1729
|
+
};
|
|
1730
|
+
|
|
1731
|
+
console.log(`📊 Final state after toggle:`, {
|
|
1732
|
+
field,
|
|
1733
|
+
dataValue: chatState.data[field],
|
|
1734
|
+
currentSelectionName: chatState.currentSelection.name
|
|
1735
|
+
});
|
|
1736
|
+
}
|
|
1726
1737
|
}
|
|
1727
1738
|
|
|
1728
1739
|
enableNextButton();
|