Skip to content

armgit / dify

Public Imported from GitHub
0

Build Agentic workflows, RAG pipelines, with rich AI model and tool support on one collaborative workspace. Deploy on cloud, VPC, or self-hosted, so teams move from prototype to production without rebuilding the stack.

fix: window size changed causes result regeneration (#1908)

Joel891218615ed5
diff --git a/web/app/components/share/text-generation/index.tsx b/web/app/components/share/text-generation/index.tsx
index a4fcf25f01b..4de8981fccb 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<IMainProps> = ({
}
}, [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<HTMLDivElement>(null)
useClickAway(() => {
hideResSidebar()
@@ -406,6 +412,16 @@ const TextGeneration: FC<IMainProps> = ({
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 = (
<div
ref={resRef}
@@ -578,22 +594,14 @@ const TextGeneration: FC<IMainProps> = ({
</div>
{/* Result */}
- {isPC && (
- <div className='grow h-full'>
- {renderResWrap}
- </div>
- )}
-
- {(!isPC && isShowResSidebar) && (
- <div
- className={cn('fixed z-50 inset-0', isTablet ? 'pl-[128px]' : 'pl-6')}
- style={{
- background: 'rgba(35, 56, 118, 0.2)',
- }}
- >
- {renderResWrap}
- </div>
- )}
+ <div
+ className={resWrapClassNames}
+ style={{
+ background: (!isPC && isShowResSidebar) ? 'rgba(35, 56, 118, 0.2)' : 'none',
+ }}
+ >
+ {renderResWrap}
+ </div>
</div>
</>
)