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

More robust edge detection #2710

Merged
merged 3 commits into from
Oct 9, 2024
Merged
Changes from 2 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
46 changes: 27 additions & 19 deletions web/src/app/chat/ChatBanner.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,13 @@ export function ChatBanner() {
useLayoutEffect(() => {
const checkOverflow = () => {
if (contentRef.current && fullContentRef.current) {
setIsOverflowing(
fullContentRef.current.scrollHeight > contentRef.current.clientHeight
);
const contentRect = contentRef.current.getBoundingClientRect();
const fullContentRect = fullContentRef.current.getBoundingClientRect();

const isWidthOverflowing = fullContentRect.width > contentRect.width;
const isHeightOverflowing = fullContentRect.height > contentRect.height;

setIsOverflowing(isWidthOverflowing || isHeightOverflowing);
}
};

Expand Down Expand Up @@ -53,23 +57,27 @@ export function ChatBanner() {
>
<div className="text-emphasis text-sm w-full">
<div className="relative">
<div
ref={contentRef}
className={`${settings.enterpriseSettings.two_lines_for_chat_header ? "line-clamp-2" : "line-clamp-1"} text-center w-full overflow-hidden pr-8`}
>
<MinimalMarkdown
className="prose text-sm max-w-full"
content={settings.enterpriseSettings.custom_header_content}
/>
<div className={`flex justify-center w-full overflow-hidden pr-8`}>
<div
ref={contentRef}
className={`overflow-hidden ${settings.enterpriseSettings.two_lines_for_chat_header ? "line-clamp-2" : "line-clamp-1"} text-center max-w-full`}
>
<MinimalMarkdown
className="prose text-sm max-w-full"
content={settings.enterpriseSettings.custom_header_content}
/>
</div>
</div>
<div
ref={fullContentRef}
className="absolute top-0 left-0 invisible w-full"
>
<MinimalMarkdown
className="prose text-sm max-w-full"
content={settings.enterpriseSettings.custom_header_content}
/>
<div className="absolute top-0 left-0 invisible flex justify-center max-w-full">
<div
ref={fullContentRef}
className={`overflow-hidden invisible${settings.enterpriseSettings.two_lines_for_chat_header ? "line-clamp-2" : "line-clamp-1"} text-center max-w-full`}
Copy link

Choose a reason for hiding this comment

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

syntax: Missing space after 'invisible' in className

>
<MinimalMarkdown
className="prose text-sm max-w-full"
content={settings.enterpriseSettings.custom_header_content}
/>
</div>
</div>
<div className="absolute bottom-0 right-0">
{isOverflowing && (
Expand Down
Loading