lisichatbot 1.4.3 → 1.4.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/package.json +1 -1
- package/src/index.js +34 -23
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -1648,6 +1648,12 @@ function handleOptionClick(element, field, isSingleSelect) {
|
|
|
1648
1648
|
} else {
|
|
1649
1649
|
const isChecked = !element.classList.contains('cf-checked');
|
|
1650
1650
|
|
|
1651
|
+
console.log(`Multi-select "${optionName}":`, {
|
|
1652
|
+
isChecked,
|
|
1653
|
+
currentData: chatState.data[field],
|
|
1654
|
+
valueToToggle: value
|
|
1655
|
+
});
|
|
1656
|
+
|
|
1651
1657
|
if (isChecked) {
|
|
1652
1658
|
element.classList.add('cf-checked');
|
|
1653
1659
|
element.style.setProperty('background-color', config.selectedBackground, 'important');
|
|
@@ -1667,20 +1673,36 @@ function handleOptionClick(element, field, isSingleSelect) {
|
|
|
1667
1673
|
chatState.data[field].push(value);
|
|
1668
1674
|
}
|
|
1669
1675
|
|
|
1670
|
-
console.log(`✅ Added "${optionName}"
|
|
1676
|
+
console.log(`✅ Added "${optionName}"`);
|
|
1677
|
+
console.log(` chatState.data.${field}:`, chatState.data[field]);
|
|
1671
1678
|
} else {
|
|
1672
1679
|
element.classList.remove('cf-checked');
|
|
1673
1680
|
element.style.setProperty('background-color', 'transparent', 'important');
|
|
1674
1681
|
if (tickIcon) tickIcon.style.setProperty('display', 'none', 'important');
|
|
1675
1682
|
if (input) input.checked = false;
|
|
1676
1683
|
|
|
1684
|
+
console.log(` BEFORE filter - chatState.data.${field}:`, chatState.data[field]);
|
|
1685
|
+
|
|
1677
1686
|
if (Array.isArray(chatState.data[field])) {
|
|
1678
|
-
|
|
1679
|
-
|
|
1680
|
-
|
|
1687
|
+
const beforeLength = chatState.data[field].length;
|
|
1688
|
+
chatState.data[field] = chatState.data[field].filter(v => {
|
|
1689
|
+
const match = JSON.stringify(v) === JSON.stringify(value);
|
|
1690
|
+
console.log(` Comparing:`, {
|
|
1691
|
+
arrayValue: v,
|
|
1692
|
+
clickedValue: value,
|
|
1693
|
+
stringifiedArray: JSON.stringify(v),
|
|
1694
|
+
stringifiedClick: JSON.stringify(value),
|
|
1695
|
+
match: match,
|
|
1696
|
+
keep: !match
|
|
1697
|
+
});
|
|
1698
|
+
return !match;
|
|
1699
|
+
});
|
|
1700
|
+
const afterLength = chatState.data[field].length;
|
|
1701
|
+
console.log(` AFTER filter - removed ${beforeLength - afterLength} items`);
|
|
1681
1702
|
}
|
|
1682
1703
|
|
|
1683
|
-
console.log(`❌ Removed "${optionName}"
|
|
1704
|
+
console.log(`❌ Removed "${optionName}"`);
|
|
1705
|
+
console.log(` chatState.data.${field}:`, chatState.data[field]);
|
|
1684
1706
|
}
|
|
1685
1707
|
|
|
1686
1708
|
const selector = `[data-field="${field}"][data-chat-element="${inputType}"].cf-checked`;
|
|
@@ -1694,6 +1716,13 @@ function handleOptionClick(element, field, isSingleSelect) {
|
|
|
1694
1716
|
value: chatState.data[field],
|
|
1695
1717
|
name: selectedNames || 'None selected'
|
|
1696
1718
|
};
|
|
1719
|
+
|
|
1720
|
+
console.log(`📊 Final state after toggle:`, {
|
|
1721
|
+
field,
|
|
1722
|
+
dataValue: chatState.data[field],
|
|
1723
|
+
currentSelectionName: chatState.currentSelection.name,
|
|
1724
|
+
checkedOptionsCount: selectedOptions.length
|
|
1725
|
+
});
|
|
1697
1726
|
}
|
|
1698
1727
|
|
|
1699
1728
|
enableNextButton();
|
|
@@ -1815,21 +1844,6 @@ async function handleNext() {
|
|
|
1815
1844
|
}
|
|
1816
1845
|
}
|
|
1817
1846
|
|
|
1818
|
-
// ✅ FIX: Remove old user message for this step (if exists)
|
|
1819
|
-
// This handles cases where user edits and changes/deselects their answer
|
|
1820
|
-
const existingUserMessage = elements.messages.querySelector(
|
|
1821
|
-
`[data-chat-element="user-message-wrapper"][data-chat-step="${chatState.step}"]`
|
|
1822
|
-
);
|
|
1823
|
-
if (existingUserMessage) {
|
|
1824
|
-
existingUserMessage.remove();
|
|
1825
|
-
console.log(` 🗑️ Removed old user message for step ${chatState.step}`);
|
|
1826
|
-
}
|
|
1827
|
-
|
|
1828
|
-
// ✅ FIX: Remove from history for this step
|
|
1829
|
-
chatState.history = chatState.history.filter(h => h.step !== chatState.step);
|
|
1830
|
-
console.log(` 🗑️ Cleared history for step ${chatState.step}`);
|
|
1831
|
-
|
|
1832
|
-
// ✅ Only add new user message if there's a selection
|
|
1833
1847
|
if (chatState.currentSelection) {
|
|
1834
1848
|
const inputConfig = currentStep.input || {};
|
|
1835
1849
|
const valueType = inputConfig.selectedInputValueType;
|
|
@@ -1849,7 +1863,6 @@ async function handleNext() {
|
|
|
1849
1863
|
if (suffix) displayName = `${displayName} ${suffix}`;
|
|
1850
1864
|
|
|
1851
1865
|
addMessage(displayName, 'user', false, chatState.step);
|
|
1852
|
-
console.log(` ✅ Added new user message: "${displayName}"`);
|
|
1853
1866
|
|
|
1854
1867
|
chatState.history.push({
|
|
1855
1868
|
step: chatState.step,
|
|
@@ -1857,8 +1870,6 @@ async function handleNext() {
|
|
|
1857
1870
|
value: chatState.currentSelection.value,
|
|
1858
1871
|
name: displayName
|
|
1859
1872
|
});
|
|
1860
|
-
} else {
|
|
1861
|
-
console.log(` ℹ️ No selection - no user message added (deselected or optional empty)`);
|
|
1862
1873
|
}
|
|
1863
1874
|
|
|
1864
1875
|
chatState.currentSelection = null;
|