feat(ST-1116): mobile auto-switch tabs + back button in BacklogSplitPane
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
6052aa81fb
commit
3e86a8d5c9
5 changed files with 218 additions and 5 deletions
34
components/backlog/backlog-split-pane.tsx
Normal file
34
components/backlog/backlog-split-pane.tsx
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
'use client'
|
||||
|
||||
import { useState } from 'react'
|
||||
import { useSelectionStore } from '@/stores/selection-store'
|
||||
import { SplitPane, type SplitPaneProps } from '@/components/split-pane/split-pane'
|
||||
|
||||
type Props = Omit<SplitPaneProps, 'activeTab' | 'onActiveTabChange'>
|
||||
|
||||
export function BacklogSplitPane(props: Props) {
|
||||
const { selectedPbiId, selectedStoryId } = useSelectionStore()
|
||||
const [activeTab, setActiveTab] = useState(0)
|
||||
|
||||
// React-recommended "derived state from props" pattern: update state during render
|
||||
// instead of useEffect to avoid cascading renders.
|
||||
const [prevPbiId, setPrevPbiId] = useState(selectedPbiId)
|
||||
const [prevStoryId, setPrevStoryId] = useState(selectedStoryId)
|
||||
|
||||
if (selectedStoryId !== prevStoryId) {
|
||||
setPrevStoryId(selectedStoryId)
|
||||
if (selectedStoryId) setActiveTab(2)
|
||||
}
|
||||
if (selectedPbiId !== prevPbiId) {
|
||||
setPrevPbiId(selectedPbiId)
|
||||
if (selectedPbiId && !selectedStoryId) setActiveTab(1)
|
||||
}
|
||||
|
||||
return (
|
||||
<SplitPane
|
||||
{...props}
|
||||
activeTab={activeTab}
|
||||
onActiveTabChange={setActiveTab}
|
||||
/>
|
||||
)
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue