From 891218615ed542635b86554aa1557a78b1af6aeb Mon Sep 17 00:00:00 2001 From: Joel Date: Thu, 4 Jan 2024 14:07:38 +0800 Subject: [PATCH] fix: window size changed causes result regeneration (#1908) --- .../share/text-generation/index.tsx | 42 +++++++++++-------- 1 file changed, 25 insertions(+), 17 deletions(-) diff --git a/web/app/components/share/text-generation/index.tsx b/web/app/components/share/text-generation/index.tsx index a4fcf25f01..4de8981fcc 100644 --- a/web/app/components/share/text-generation/index.tsx +++ b/web/app/components/share/text-generation/index.tsx @@ -374,7 +374,13 @@ const TextGeneration: FC = ({ } }, [siteInfo?.title, canReplaceLogo]) - const [isShowResSidebar, { setTrue: showResSidebar, setFalse: hideResSidebar }] = useBoolean(false) + const [isShowResSidebar, { setTrue: doShowResSidebar, setFalse: hideResSidebar }] = useBoolean(false) + const showResSidebar = () => { + // fix: useClickAway hideResSidebar will close sidebar + setTimeout(() => { + doShowResSidebar() + }, 0) + } const resRef = useRef(null) useClickAway(() => { hideResSidebar() @@ -406,6 +412,16 @@ const TextGeneration: FC = ({ return (showTaskList.map(task => renderRes(task))) } + const resWrapClassNames = (() => { + if (isPC) + return 'grow h-full' + + if (!isShowResSidebar) + return 'none' + + return cn('fixed z-50 inset-0', isTablet ? 'pl-[128px]' : 'pl-6') + })() + const renderResWrap = (
= ({
{/* Result */} - {isPC && ( -
- {renderResWrap} -
- )} - - {(!isPC && isShowResSidebar) && ( -
- {renderResWrap} -
- )} +
+ {renderResWrap} +
)