lisichatbot 1.6.6 → 1.6.7
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 +44 -90
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -48,16 +48,29 @@ let flowData = null;
|
|
|
48
48
|
// =============================================================================
|
|
49
49
|
|
|
50
50
|
function scrollToBottom() {
|
|
51
|
-
if (elements.messages)
|
|
52
|
-
|
|
51
|
+
if (!elements.messages) return;
|
|
52
|
+
|
|
53
|
+
// ✅ NEW: Ensure the very last child is fully visible
|
|
54
|
+
const scrollToLastElement = () => {
|
|
55
|
+
const lastChild = elements.messages.lastElementChild;
|
|
56
|
+
if (lastChild) {
|
|
57
|
+
lastChild.scrollIntoView({ behavior: 'smooth', block: 'end', inline: 'nearest' });
|
|
58
|
+
console.log(` 📜 Scrolled last element into view`);
|
|
59
|
+
} else {
|
|
60
|
+
// Fallback to scrollHeight
|
|
61
|
+
elements.messages.scrollTop = elements.messages.scrollHeight;
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
// Immediate scroll
|
|
66
|
+
scrollToLastElement();
|
|
67
|
+
|
|
68
|
+
// ✅ Use requestAnimationFrame to ensure DOM layout is complete
|
|
69
|
+
requestAnimationFrame(() => {
|
|
53
70
|
requestAnimationFrame(() => {
|
|
54
|
-
|
|
55
|
-
// Double RAF ensures layout is complete
|
|
56
|
-
elements.messages.scrollTop = elements.messages.scrollHeight;
|
|
57
|
-
console.log(` 📜 Scrolled to bottom: ${elements.messages.scrollHeight}px`);
|
|
58
|
-
});
|
|
71
|
+
scrollToLastElement();
|
|
59
72
|
});
|
|
60
|
-
}
|
|
73
|
+
});
|
|
61
74
|
}
|
|
62
75
|
|
|
63
76
|
function enableNextButton() {
|
|
@@ -2011,10 +2024,6 @@ async function handleNext() {
|
|
|
2011
2024
|
console.log('💬 showMessage called:', message);
|
|
2012
2025
|
addMessage(message, 'bot', false, null);
|
|
2013
2026
|
scrollToBottom();
|
|
2014
|
-
// ✅ Delayed scroll to ensure message is fully rendered
|
|
2015
|
-
setTimeout(() => {
|
|
2016
|
-
scrollToBottom();
|
|
2017
|
-
}, 100);
|
|
2018
2027
|
};
|
|
2019
2028
|
|
|
2020
2029
|
// ✅ Pass showMessage as third parameter
|
|
@@ -2029,10 +2038,6 @@ async function handleNext() {
|
|
|
2029
2038
|
console.log('💬 onNext displaying message from return:', result.showMessage);
|
|
2030
2039
|
addMessage(result.showMessage, 'bot', false, null);
|
|
2031
2040
|
scrollToBottom();
|
|
2032
|
-
// ✅ Delayed scroll to ensure message is fully rendered
|
|
2033
|
-
setTimeout(() => {
|
|
2034
|
-
scrollToBottom();
|
|
2035
|
-
}, 100);
|
|
2036
2041
|
}
|
|
2037
2042
|
|
|
2038
2043
|
// ✅ NEW: Check if onNext wants to update steps by field name
|
|
@@ -2167,20 +2172,8 @@ async function handleNext() {
|
|
|
2167
2172
|
disableNextButton();
|
|
2168
2173
|
await showNextStep();
|
|
2169
2174
|
|
|
2170
|
-
// ✅
|
|
2171
|
-
|
|
2172
|
-
scrollToBottom();
|
|
2173
|
-
}, 350);
|
|
2174
|
-
|
|
2175
|
-
// ✅ NEW: Additional delayed scroll for cases with multiple showMessage calls
|
|
2176
|
-
setTimeout(() => {
|
|
2177
|
-
scrollToBottom();
|
|
2178
|
-
}, 500);
|
|
2179
|
-
|
|
2180
|
-
// ✅ NEW: Final scroll for steps with multiple inputs
|
|
2181
|
-
setTimeout(() => {
|
|
2182
|
-
scrollToBottom();
|
|
2183
|
-
}, 800);
|
|
2175
|
+
// ✅ Single scroll call - MutationObserver will handle the rest
|
|
2176
|
+
scrollToBottom();
|
|
2184
2177
|
|
|
2185
2178
|
return;
|
|
2186
2179
|
} else {
|
|
@@ -2406,16 +2399,8 @@ async function handleNext() {
|
|
|
2406
2399
|
|
|
2407
2400
|
await showNextStep();
|
|
2408
2401
|
|
|
2409
|
-
// ✅
|
|
2410
|
-
|
|
2411
|
-
setTimeout(() => {
|
|
2412
|
-
scrollToBottom();
|
|
2413
|
-
}, 350);
|
|
2414
|
-
|
|
2415
|
-
// ✅ NEW: Additional scroll for steps with multiple inputs
|
|
2416
|
-
setTimeout(() => {
|
|
2417
|
-
scrollToBottom();
|
|
2418
|
-
}, 700);
|
|
2402
|
+
// ✅ Final scroll after showNextStep completes
|
|
2403
|
+
scrollToBottom();
|
|
2419
2404
|
}
|
|
2420
2405
|
|
|
2421
2406
|
// ✅ NEW: Helper function to find next step that is accessible in normal flow
|
|
@@ -2482,10 +2467,6 @@ async function showNextStep() {
|
|
|
2482
2467
|
console.log('💬 showMessage called:', message);
|
|
2483
2468
|
addMessage(message, 'bot', false, null);
|
|
2484
2469
|
scrollToBottom();
|
|
2485
|
-
// ✅ Delayed scroll to ensure message is fully rendered
|
|
2486
|
-
setTimeout(() => {
|
|
2487
|
-
scrollToBottom();
|
|
2488
|
-
}, 100);
|
|
2489
2470
|
};
|
|
2490
2471
|
|
|
2491
2472
|
// ✅ Pass showMessage as second parameter
|
|
@@ -2496,10 +2477,6 @@ async function showNextStep() {
|
|
|
2496
2477
|
console.log('💬 onStart displaying message from return:', result.showMessage);
|
|
2497
2478
|
addMessage(result.showMessage, 'bot', false, null);
|
|
2498
2479
|
scrollToBottom();
|
|
2499
|
-
// ✅ Delayed scroll to ensure message is fully rendered
|
|
2500
|
-
setTimeout(() => {
|
|
2501
|
-
scrollToBottom();
|
|
2502
|
-
}, 100);
|
|
2503
2480
|
}
|
|
2504
2481
|
|
|
2505
2482
|
// ✅ NEW: Check if onStart wants to update steps by field name
|
|
@@ -2675,25 +2652,16 @@ async function showNextStep() {
|
|
|
2675
2652
|
console.log(` 🔓 Override active for fields:`, chatState.prefillOverrideFields);
|
|
2676
2653
|
}
|
|
2677
2654
|
|
|
2655
|
+
// ✅ Check if we're jumping from the very first step (needs extra time to initialize)
|
|
2656
|
+
const isJumpingFromFirstStep = chatState.step === 0;
|
|
2657
|
+
|
|
2678
2658
|
chatState.step = targetStepIndex;
|
|
2679
2659
|
chatState.currentSelection = null;
|
|
2680
2660
|
disableNextButton();
|
|
2681
2661
|
await showNextStep();
|
|
2682
2662
|
|
|
2683
|
-
// ✅
|
|
2684
|
-
|
|
2685
|
-
scrollToBottom();
|
|
2686
|
-
}, 350);
|
|
2687
|
-
|
|
2688
|
-
// ✅ NEW: Additional delayed scroll for cases with multiple showMessage calls
|
|
2689
|
-
setTimeout(() => {
|
|
2690
|
-
scrollToBottom();
|
|
2691
|
-
}, 500);
|
|
2692
|
-
|
|
2693
|
-
// ✅ NEW: Final scroll for steps with multiple inputs
|
|
2694
|
-
setTimeout(() => {
|
|
2695
|
-
scrollToBottom();
|
|
2696
|
-
}, 800);
|
|
2663
|
+
// ✅ Single scroll call - MutationObserver will handle the rest
|
|
2664
|
+
scrollToBottom();
|
|
2697
2665
|
|
|
2698
2666
|
return;
|
|
2699
2667
|
} else {
|
|
@@ -2723,25 +2691,16 @@ async function showNextStep() {
|
|
|
2723
2691
|
console.log(` 🔓 Override active for fields:`, chatState.prefillOverrideFields);
|
|
2724
2692
|
}
|
|
2725
2693
|
|
|
2694
|
+
// ✅ Check if we're jumping from the very first step (needs extra time to initialize)
|
|
2695
|
+
const isJumpingFromFirstStep = chatState.step === 0;
|
|
2696
|
+
|
|
2726
2697
|
chatState.step = targetStep;
|
|
2727
2698
|
chatState.currentSelection = null;
|
|
2728
2699
|
disableNextButton();
|
|
2729
2700
|
await showNextStep();
|
|
2730
2701
|
|
|
2731
|
-
// ✅
|
|
2732
|
-
|
|
2733
|
-
scrollToBottom();
|
|
2734
|
-
}, 350);
|
|
2735
|
-
|
|
2736
|
-
// ✅ NEW: Additional delayed scroll for cases with multiple showMessage calls
|
|
2737
|
-
setTimeout(() => {
|
|
2738
|
-
scrollToBottom();
|
|
2739
|
-
}, 500);
|
|
2740
|
-
|
|
2741
|
-
// ✅ NEW: Final scroll for steps with multiple inputs
|
|
2742
|
-
setTimeout(() => {
|
|
2743
|
-
scrollToBottom();
|
|
2744
|
-
}, 800);
|
|
2702
|
+
// ✅ Single scroll call - MutationObserver will handle the rest
|
|
2703
|
+
scrollToBottom();
|
|
2745
2704
|
|
|
2746
2705
|
return;
|
|
2747
2706
|
} else {
|
|
@@ -2961,20 +2920,15 @@ async function showNextStep() {
|
|
|
2961
2920
|
updateEditIcons();
|
|
2962
2921
|
}, 10);
|
|
2963
2922
|
|
|
2964
|
-
// ✅
|
|
2965
|
-
|
|
2966
|
-
|
|
2967
|
-
|
|
2968
|
-
|
|
2969
|
-
|
|
2970
|
-
|
|
2971
|
-
|
|
2972
|
-
}
|
|
2973
|
-
|
|
2974
|
-
// ✅ NEW: Final scroll for complex steps with multiple inputs or slow rendering
|
|
2975
|
-
setTimeout(() => {
|
|
2976
|
-
scrollToBottom();
|
|
2977
|
-
}, 600);
|
|
2923
|
+
// ✅ Final scroll after all rendering completes
|
|
2924
|
+
requestAnimationFrame(() => {
|
|
2925
|
+
requestAnimationFrame(() => {
|
|
2926
|
+
requestAnimationFrame(() => {
|
|
2927
|
+
// Triple RAF to ensure everything is laid out
|
|
2928
|
+
scrollToBottom();
|
|
2929
|
+
});
|
|
2930
|
+
});
|
|
2931
|
+
});
|
|
2978
2932
|
}
|
|
2979
2933
|
|
|
2980
2934
|
function handleCompletion() {
|