perf: Replace topOffset prop with withHeader in Panel component

This commit is contained in:
zhsama
2026-01-15 16:44:15 +08:00
parent e89d4e14ea
commit 2e10d67610
3 changed files with 8 additions and 7 deletions

View File

@ -76,7 +76,7 @@ const SubGraphChildren: FC<SubGraphChildrenProps> = ({
return (
<Panel
topOffset={0}
withHeader={false}
components={{
right: panelRight,
}}

View File

@ -7,7 +7,6 @@ import { memo, useEffect, useMemo } from 'react'
import WorkflowWithDefaultContext from '@/app/components/workflow'
import { NODE_WIDTH_X_OFFSET, START_INITIAL_POSITION } from '@/app/components/workflow/constants'
import { WorkflowContextProvider } from '@/app/components/workflow/context'
import { useHooksStore } from '@/app/components/workflow/hooks-store'
import { useStore } from '@/app/components/workflow/store'
import { BlockEnum, EditionType, isPromptMessageContext, PromptRole } from '@/app/components/workflow/types'
import SubGraphMain from './components/sub-graph-main'
@ -42,12 +41,12 @@ const SubGraphContent: FC<SubGraphProps> = (props) => {
toolParamValue,
parentAvailableNodes,
parentAvailableVars,
configsMap,
onSave,
} = props
const setParentAvailableVars = useStore(state => state.setParentAvailableVars)
const setParentAvailableNodes = useStore(state => state.setParentAvailableNodes)
const configsMap = useHooksStore(state => state.configsMap)
useEffect(() => {
setParentAvailableVars?.(parentAvailableVars || [])

View File

@ -19,7 +19,7 @@ export type PanelProps = {
right?: React.ReactNode
}
versionHistoryPanelProps?: VersionHistoryPanelProps
topOffset?: number
withHeader?: boolean
}
/**
@ -70,7 +70,7 @@ const useResizeObserver = (
const Panel: FC<PanelProps> = ({
components,
versionHistoryPanelProps,
topOffset,
withHeader = true,
}) => {
const selectedNode = useReactflow(useShallow((s) => {
const nodes = s.getNodes()
@ -129,8 +129,10 @@ const Panel: FC<PanelProps> = ({
<div
ref={rightPanelRef}
tabIndex={-1}
className={cn('absolute bottom-1 right-0 top-14 z-10 flex outline-none')}
style={topOffset === undefined ? undefined : { top: `${topOffset}px` }}
className={cn(
'absolute bottom-1 right-0 z-10 flex outline-none',
withHeader ? 'top-14' : 'top-0',
)}
key={`${isRestoring}`}
>
{components?.left}