@landtrustinc/design-system 1.2.46-beta.1 → 1.2.46-beta.2
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/dist/index.js +5 -2
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -6605,6 +6605,7 @@ var ChatWidget = ({
|
|
|
6605
6605
|
const scrollRef = (0, import_react36.useRef)(null);
|
|
6606
6606
|
const savedScrollPosition = (0, import_react36.useRef)(0);
|
|
6607
6607
|
const previousMessagesLength = (0, import_react36.useRef)(messages.length);
|
|
6608
|
+
const previousMessagesRef = (0, import_react36.useRef)(messages);
|
|
6608
6609
|
const isControlled = typeof expanded === "boolean";
|
|
6609
6610
|
const [internalExpanded, setInternalExpanded] = (0, import_react36.useState)(defaultExpanded);
|
|
6610
6611
|
const isExpanded = isControlled ? expanded : internalExpanded;
|
|
@@ -6633,9 +6634,11 @@ var ChatWidget = ({
|
|
|
6633
6634
|
const el = scrollRef.current;
|
|
6634
6635
|
if (!el || !isExpanded)
|
|
6635
6636
|
return;
|
|
6636
|
-
const
|
|
6637
|
+
const messagesLengthChanged = messages.length !== previousMessagesLength.current;
|
|
6638
|
+
const messagesContentChanged = messages !== previousMessagesRef.current;
|
|
6637
6639
|
previousMessagesLength.current = messages.length;
|
|
6638
|
-
|
|
6640
|
+
previousMessagesRef.current = messages;
|
|
6641
|
+
if (messagesLengthChanged || messagesContentChanged || isThinking) {
|
|
6639
6642
|
requestAnimationFrame(() => {
|
|
6640
6643
|
el.scrollTo({ top: el.scrollHeight, behavior: "smooth" });
|
|
6641
6644
|
savedScrollPosition.current = el.scrollHeight;
|