fix(intake): keep product library content in the viewport
This commit is contained in:
parent
b229d5303c
commit
4e4226416e
@ -252,6 +252,8 @@ export function ProductWorkspaceTabs({
|
||||
|
||||
const showRouteBar = Boolean(label && pathname !== INTAKE_PATH && pathname !== PRODUCT_LIBRARY_PATH)
|
||||
const intakePanelReady = pathname === INTAKE_PATH && Boolean(activePanel)
|
||||
// The retained panel takes over the viewport from the original route container.
|
||||
const showRouteContent = !parkRoute && !activePanel
|
||||
return (
|
||||
<TabsContext.Provider value={{
|
||||
isIntake: pathname === INTAKE_PATH,
|
||||
@ -268,7 +270,7 @@ export function ProductWorkspaceTabs({
|
||||
{renderTabBar(collectTabs(pages, intakeTabs), pathname)}
|
||||
</div>
|
||||
)}
|
||||
<div className={parkRoute || intakePanelReady ? 'hidden' : showRouteBar ? 'min-h-0 flex-1' : 'contents'}>
|
||||
<div hidden={!showRouteContent} className={showRouteContent ? (showRouteBar ? 'min-h-0 flex-1' : 'contents') : undefined}>
|
||||
<Activity mode={parkRoute ? 'hidden' : 'visible'}>{children}</Activity>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@ -73,3 +73,40 @@ describe('产品信息正文加载', () => {
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
describe('共用工作页签的正文布局', () => {
|
||||
it.each([
|
||||
{ path: '/intake', routeSegments: ['intake'], title: '产品信息' },
|
||||
{ path: '/intake/product-library', routeSegments: ['intake', 'product-library'], title: '产品资料' },
|
||||
])('$title 的正文接管首屏,并在切回时复用', ({ path, routeSegments, title }) => {
|
||||
const navigate = jest.fn()
|
||||
const renderPage = (pathname: string, route: React.ReactNode) => (
|
||||
<ProductWorkspaceTabs pathname={pathname} search="" sessionUser={account} navigate={navigate}>
|
||||
<div data-testid="route-root" className="h-full">{route}</div>
|
||||
</ProductWorkspaceTabs>
|
||||
)
|
||||
const panel = (
|
||||
<IntakeRoutePanel path={path} userId={account.id}>
|
||||
<input aria-label={`${title}筛选`} defaultValue="" />
|
||||
</IntakeRoutePanel>
|
||||
)
|
||||
|
||||
segments = routeSegments
|
||||
const { rerender } = render(renderPage(path, panel))
|
||||
const filter = screen.getByRole('textbox', { name: `${title}筛选` })
|
||||
expect(filter).toBeVisible()
|
||||
expect(screen.getByTestId('route-root')).not.toBeVisible()
|
||||
|
||||
segments = ['database', 'boards']
|
||||
const boards = <h1>板材资料库正文</h1>
|
||||
rerender(renderPage('/database/boards', boards))
|
||||
expect(screen.getByRole('heading', { name: '板材资料库正文' })).toBeVisible()
|
||||
expect(filter).not.toBeVisible()
|
||||
|
||||
rerender(renderPage(path, boards))
|
||||
expect(screen.getByRole('textbox', { name: `${title}筛选` })).toBe(filter)
|
||||
expect(filter).toBeVisible()
|
||||
expect(screen.getByTestId('route-root')).not.toBeVisible()
|
||||
expect(navigate).not.toHaveBeenCalled()
|
||||
})
|
||||
})
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user