Unverified Commit 89121861 authored by Joel's avatar Joel Committed by GitHub

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

parent a938e1f1
......@@ -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')}
className={resWrapClassNames}
style={{
background: 'rgba(35, 56, 118, 0.2)',
background: (!isPC && isShowResSidebar) ? 'rgba(35, 56, 118, 0.2)' : 'none',
}}
>
{renderResWrap}
</div>
)}
</div>
</>
)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment