lisichatbot 2.1.6 → 2.1.8
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 +23 -5
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -23,7 +23,8 @@ let chatState = {
|
|
|
23
23
|
editSteps: null, // ✅ Array of step indices to walk through in edit-steps mode
|
|
24
24
|
editStepsIndex: 0, // ✅ Current position within editSteps array
|
|
25
25
|
onEditComplete: null, // ✅ Callback when editSteps flow finishes
|
|
26
|
-
editFinalButtonText: null // ✅ Button text for the last step in editSteps
|
|
26
|
+
editFinalButtonText: null, // ✅ Button text for the last step in editSteps
|
|
27
|
+
autoAdvanceTimer: null // ✅ Track auto-advance timeout so it can be cleared
|
|
27
28
|
};
|
|
28
29
|
|
|
29
30
|
let elements = {
|
|
@@ -1538,7 +1539,9 @@ function handleCustomSelectClick(element, field, customConfig) {
|
|
|
1538
1539
|
const delay = currentStep.autoAdvanceDelay || 500;
|
|
1539
1540
|
// console.log(` ⏱️ Waiting ${delay}ms before advancing`);
|
|
1540
1541
|
|
|
1541
|
-
|
|
1542
|
+
if (chatState.autoAdvanceTimer) clearTimeout(chatState.autoAdvanceTimer);
|
|
1543
|
+
chatState.autoAdvanceTimer = setTimeout(() => {
|
|
1544
|
+
chatState.autoAdvanceTimer = null;
|
|
1542
1545
|
if (elements.nextBtn && !elements.nextBtn.disabled) {
|
|
1543
1546
|
// console.log(' ▶️ Auto-advancing to next step');
|
|
1544
1547
|
handleNext();
|
|
@@ -2007,7 +2010,9 @@ function handleOptionClick(element, field, isSingleSelect, options) {
|
|
|
2007
2010
|
const delay = currentStep.autoAdvanceDelay || 500;
|
|
2008
2011
|
// console.log(` ⏱️ Waiting ${delay}ms before advancing`);
|
|
2009
2012
|
|
|
2010
|
-
|
|
2013
|
+
if (chatState.autoAdvanceTimer) clearTimeout(chatState.autoAdvanceTimer);
|
|
2014
|
+
chatState.autoAdvanceTimer = setTimeout(() => {
|
|
2015
|
+
chatState.autoAdvanceTimer = null;
|
|
2011
2016
|
if (elements.nextBtn && !elements.nextBtn.disabled) {
|
|
2012
2017
|
// console.log(' ▶️ Auto-advancing to next step');
|
|
2013
2018
|
handleNext();
|
|
@@ -2372,11 +2377,17 @@ async function handleNext() {
|
|
|
2372
2377
|
// console.log(` 🔓 Override active for fields:`, chatState.prefillOverrideFields);
|
|
2373
2378
|
}
|
|
2374
2379
|
|
|
2380
|
+
// ✅ Clear any pending auto-advance timer
|
|
2381
|
+
if (chatState.autoAdvanceTimer) {
|
|
2382
|
+
clearTimeout(chatState.autoAdvanceTimer);
|
|
2383
|
+
chatState.autoAdvanceTimer = null;
|
|
2384
|
+
}
|
|
2385
|
+
|
|
2375
2386
|
chatState.step = targetStepIndex;
|
|
2376
2387
|
chatState.currentSelection = null;
|
|
2377
2388
|
disableNextButton();
|
|
2378
2389
|
await showNextStep();
|
|
2379
|
-
|
|
2390
|
+
|
|
2380
2391
|
// ✅ NEW: Extra scroll after jump to ensure inputs are visible
|
|
2381
2392
|
setTimeout(() => {
|
|
2382
2393
|
scrollToBottom();
|
|
@@ -3116,9 +3127,15 @@ async function showNextStep() {
|
|
|
3116
3127
|
// console.log(` 🔓 Override active for fields:`, chatState.prefillOverrideFields);
|
|
3117
3128
|
}
|
|
3118
3129
|
|
|
3130
|
+
// ✅ Clear any pending auto-advance timer
|
|
3131
|
+
if (chatState.autoAdvanceTimer) {
|
|
3132
|
+
clearTimeout(chatState.autoAdvanceTimer);
|
|
3133
|
+
chatState.autoAdvanceTimer = null;
|
|
3134
|
+
}
|
|
3135
|
+
|
|
3119
3136
|
// ✅ Check if we're jumping from the very first step (needs extra time to initialize)
|
|
3120
3137
|
const isJumpingFromFirstStep = chatState.step === 0;
|
|
3121
|
-
|
|
3138
|
+
|
|
3122
3139
|
chatState.step = targetStepIndex;
|
|
3123
3140
|
chatState.currentSelection = null;
|
|
3124
3141
|
disableNextButton();
|
|
@@ -3476,6 +3493,7 @@ async function showNextStep() {
|
|
|
3476
3493
|
// console.log(' 👁️ Next button shown (nextButtonDisplay: true or undefined)');
|
|
3477
3494
|
} else {
|
|
3478
3495
|
elements.nextBtn.style.display = 'none';
|
|
3496
|
+
elements.nextBtn.disabled = true;
|
|
3479
3497
|
// console.log(' 🙈 Next button hidden (nextButtonDisplay: false)');
|
|
3480
3498
|
}
|
|
3481
3499
|
}
|