Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix chat list double scrollbar #3385

Merged
merged 4 commits into from
Jun 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion website/src/components/Chat/ChatConversation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import SimpleBar from "simplebar-react";
import { useMessageVote } from "src/hooks/chat/useMessageVote";
import { useBrowserConfig } from "src/hooks/env/BrowserEnv";
import { get, post } from "src/lib/api";
import { handleChatEventStream, QueueInfo, PluginIntermediateResponse } from "src/lib/chat_stream";
import { handleChatEventStream, PluginIntermediateResponse, QueueInfo } from "src/lib/chat_stream";
import { OasstError } from "src/lib/oasst_api_client";
import { API_ROUTES } from "src/lib/routes";
import {
Expand Down
43 changes: 29 additions & 14 deletions website/src/components/Chat/ChatListBase.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ import { ChatListViewSelection, useListChatPagination } from "./useListChatPagin

export const ChatListBase = memo(function ChatListBase({
allowViews,
minHeight,
noScrollbar,
...props
}: CardProps & { allowViews?: boolean; minHeight?: string }) {
}: CardProps & { allowViews?: boolean; noScrollbar?: boolean }) {
const [view, setView] = useState<ChatListViewSelection>("visible");
const { loadMoreRef, responses, mutateChatResponses } = useListChatPagination(view);
const chats = responses?.flatMap((response) => response.chats) || [];
Expand Down Expand Up @@ -67,6 +67,21 @@ export const ChatListBase = memo(function ChatListBase({
mutateChatResponses();
}, [mutateChatResponses]);

const content = (
<>
{chats.map((chat) => (
<ChatListItem
key={chat.id}
chat={chat}
onUpdateTitle={handleUpdateTitle}
onHide={removeItemFromList}
onDelete={removeItemFromList}
/>
))}
<div ref={loadMoreRef} />
</>
);

return (
<Box
gap="1"
Expand Down Expand Up @@ -96,18 +111,18 @@ export const ChatListBase = memo(function ChatListBase({
<ChatViewSelection w={["full", "auto"]} onChange={(e) => setView(e.target.value as ChatListViewSelection)} />
)}
</Flex>
<SimpleBar style={{ padding: "8px", height: "100%", minHeight: chats.length && minHeight ? minHeight : "0" }}>
{chats.map((chat) => (
<ChatListItem
key={chat.id}
chat={chat}
onUpdateTitle={handleUpdateTitle}
onHide={removeItemFromList}
onDelete={removeItemFromList}
/>
))}
<div ref={loadMoreRef} />
</SimpleBar>
{noScrollbar ? (
content
) : (
<SimpleBar
style={{ padding: "8px", height: "100%", minHeight: "150px" }}
classNames={{
contentEl: "flex flex-col items-center overflow-y-hidden min-h-full",
}}
>
{content}
</SimpleBar>
)}
<InferencePoweredBy />
</Box>
);
Expand Down
3 changes: 2 additions & 1 deletion website/src/components/Chat/ChatListItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,8 @@ const ChatListItemIconButton = ({ label, onClick, icon }: ChatListItemIconButton
return (
<Tooltip label={label}>
<Box
as="button"
as="div"
role="button"
Comment on lines +309 to +310
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fix this bug
validateDOMNesting(...): <button> cannot appear as a descendant of <button>.

aria-label={label}
onClick={(e: MouseEvent) => {
stopEvent(e);
Expand Down
4 changes: 2 additions & 2 deletions website/src/pages/chat/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { DashboardLayout } from "src/components/Layout";
export { getStaticProps } from "src/lib/defaultServerSideProps";

const ChatList = () => {
const { t } = useTranslation(["chat"]);
const { t } = useTranslation();

return (
<>
Expand All @@ -27,7 +27,7 @@ const ChatList = () => {
bg: "gray.700",
}}
shadow="md"
minHeight="300px"
noScrollbar
/>
</>
);
Expand Down