@vendorflow/components 2.0.35 → 2.0.36

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.
@@ -80,11 +80,17 @@ function useInfiniteScroll(_a) {
80
80
  var scrollParent = _a.scrollParent, scrollBody = _a.scrollBody, isLoading = _a.isLoading, isFetching = _a.isFetching, isReverse = _a.isReverse, hasNextPage = _a.hasNextPage, fetchNextPage = _a.fetchNextPage;
81
81
  var prevPosition = (0, react_2.useRef)();
82
82
  var observer = (0, react_2.useRef)();
83
+ var hasScrollbar = (0, react_2.useMemo)(function () {
84
+ if (scrollParent.current && scrollBody.current) {
85
+ return scrollBody.current.clientHeight > scrollParent.current.clientHeight;
86
+ }
87
+ return false;
88
+ }, [scrollParent, scrollBody]);
83
89
  (0, react_2.useEffect)(function () {
84
- if (!isLoading) {
90
+ if (!isLoading && hasScrollbar) {
85
91
  scrollToStart();
86
92
  }
87
- }, [isLoading]);
93
+ }, [isLoading, hasScrollbar]);
88
94
  function scrollToStart() {
89
95
  var _a;
90
96
  var scrollHeight = (scrollBody.current || { scrollHeight: 0 }).scrollHeight;
@@ -134,7 +134,7 @@ function ChatInterface() {
134
134
  setTimeout(function () {
135
135
  setMessages(__spreadArray(__spreadArray([], __read(messages), false), __read(generateMessagePage()), false));
136
136
  setFetching(false);
137
- }, 20);
137
+ }, 1000);
138
138
  }
139
139
  function handleSend(message) {
140
140
  setSubmitting(true);
@@ -154,7 +154,7 @@ function ChatInterface() {
154
154
  }, 500);
155
155
  });
156
156
  }
157
- return ((0, react_1.jsx)("div", { css: (0, react_1.css)(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n border: 1px solid #ededed;\n height: 30rem;\n "], ["\n border: 1px solid #ededed;\n height: 30rem;\n "]))) },
157
+ return ((0, react_1.jsx)("div", { css: (0, react_1.css)(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n border: 1px solid #ededed;\n height: 40rem;\n "], ["\n border: 1px solid #ededed;\n height: 40rem;\n "]))) },
158
158
  (0, react_1.jsx)(ChatInterface_1.default, { userId: "user1", messages: messages, handleSend: handleSend, submitting: submitting, fetchNextPage: loadMore, hasNextPage: hasMore, isLoading: isLoading, isFetching: isFetching })));
159
159
  }
160
160
  exports.ChatInterface = ChatInterface;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vendorflow/components",
3
- "version": "2.0.35",
3
+ "version": "2.0.36",
4
4
  "description": "React components for vendorflow",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",