@@ -27,6 +27,7 @@ import { TimelineTrackRow } from "./TimelineTrackRow";
2727import { isTimelineClipActive } from "./useTimelineActiveClips" ;
2828import { queryTimelineClipIndex } from "../lib/timelineClipIndex" ;
2929import { getTimelineElementIdentity } from "../lib/timelineElementHelpers" ;
30+ import { useTimelineLogicalRows } from "./useTimelineLogicalRows" ;
3031
3132interface TimelineLanesProps extends TimelineLaneBaseProps {
3233 /** Live-derived by TimelineCanvas from {@link TimelineLaneBaseProps.draggedClip}. */
@@ -99,14 +100,20 @@ export function TimelineLanes({
99100 onRazorSplit,
100101 onRazorSplitAll,
101102} : TimelineLanesProps ) {
102- // Per-INSTANCE, so two timelines on one page (a mini-timeline in a modal
103- // beside the main one) cannot both mint `...-track-0` and have every caret's
104- // aria-controls resolve to whichever mounted first. React's useId embeds
105- // colons, which are legal in an id and in aria-controls but need escaping in
106- // a CSS `#id` selector, so they come out here and the prefix stays plain.
103+ // ponytail: One per-instance namespace prevents aria-controls and aria-owns
104+ // from resolving into a second timeline that renders the same logical rows.
107105 const lanesIdPrefix = `timeline-lanes${ useId ( ) . replaceAll ( ":" , "" ) } ` ;
108106 const expandedClipIds = usePlayerStore ( ( s ) => s . expandedClipIds ) ;
109107 const toggleClipExpanded = usePlayerStore ( ( s ) => s . toggleClipExpanded ) ;
108+ const { logicalRows, logicalRowsByTrack } = useTimelineLogicalRows ( {
109+ tracks,
110+ displayTrackOrder,
111+ laneCounts,
112+ selectedElementId,
113+ selectedElementIds,
114+ expandedClipIds,
115+ gsapAnimations,
116+ } ) ;
110117 const toggleClipExpandedTracked = ( key : string ) => {
111118 const willExpand = ! expandedClipIds . has ( key ) ;
112119 trackStudioKeyframeLaneExpand ( { expanded : willExpand } ) ;
@@ -130,8 +137,10 @@ export function TimelineLanes({
130137 : [ ] ;
131138 return (
132139 < div
133- role = "list "
140+ role = "treegrid "
134141 aria-label = "Timeline tracks"
142+ aria-multiselectable = "true"
143+ aria-rowcount = { logicalRows . length }
135144 className = { rowsVirtualized ? "absolute inset-0" : undefined }
136145 >
137146 {
@@ -140,6 +149,9 @@ export function TimelineLanes({
140149 const trackNum = displayTrackOrder [ row ] ;
141150 if ( trackNum === undefined ) return null ;
142151 const displayNumber = trackDisplayNumber ( displayTrackOrder , trackNum ) ;
152+ const trackLogicalRows = logicalRowsByTrack . get ( trackNum ) ?? [ ] ;
153+ const logicalRow = trackLogicalRows [ 0 ] ;
154+ if ( ! logicalRow ) return null ;
143155 const rowHeight = rowGeometry . getRowHeight ( row ) ;
144156 const els = tracks . find ( ( [ t ] ) => t === trackNum ) ?. [ 1 ] ?? [ ] ;
145157 const renderElements = rowsVirtualized
@@ -156,19 +168,15 @@ export function TimelineLanes({
156168 draggedClip ?. started === true && ! trackOrder . includes ( trackNum ) && els . length === 0 ;
157169 // All lanes use the same uniform color — no alternating stripes.
158170 const rowBackground = theme . rowBackground ;
159- // The beat-dot strip occupies the top of this track's lane (active track,
160- // or the music track when nothing is selected). When shown, keyframe
161- // diamonds shrink + drop to the bottom half so they don't collide with it.
171+ // Keep diamonds below the beat strip on the active/music track.
162172 const beatStripOnTrack =
163173 ( beatAnalysis ?. beatTimes ?. length ?? 0 ) >= 2 &&
164174 ( selectedElementId
165175 ? els . some ( ( e ) => ( e . key ?? e . id ) === selectedElementId )
166176 : els . some ( isMusicTrack ) ) ;
167177 const isTrackHidden = els . length > 0 && els . every ( ( element ) => element . hidden === true ) ;
168178 const isAudioTrack = els . length > 0 && els . some ( isAudioTimelineElement ) ;
169- // The one keyframed element this track shows lanes for (selected, else
170- // most lanes). A track can hold several elements; scoping to one keeps
171- // their keyframes from cramming into a single row.
179+ // Only the selected/most-keyframed clip owns expanded lanes on a shared track.
172180 const keyframeClip = resolveTrackKeyframeClip (
173181 els ,
174182 laneCounts ,
@@ -178,17 +186,16 @@ export function TimelineLanes({
178186 const keyframeClipKey = keyframeClip ?. key ?? keyframeClip ?. id ;
179187 const keyframeClipExpanded =
180188 keyframeClipKey != null && expandedClipIds . has ( keyframeClipKey ) ;
181- // Minted here because this is the only place that sees BOTH ends of
182- // the disclosure: the caret in the sticky header and the diamond lanes
183- // on the canvas. Keyed by display row, not by `trackNum`, which is a
184- // fractional sort key and would mint ids like `...-0.16666666666666666`.
189+ // Link the sticky caret to the canvas lanes with a stable display-row id.
185190 const lanesId = `${ lanesIdPrefix } -track-${ row } ` ;
186191 return (
187192 < TimelineTrackRow
188193 key = { rowKey }
189194 index = { row }
190195 rowKey = { rowKey }
191- rowCount = { displayTrackOrder . length }
196+ logicalRow = { logicalRow }
197+ propertyRows = { trackLogicalRows . slice ( 1 ) }
198+ lanesId = { lanesId }
192199 top = { rowGeometry . getRowTop ( row ) }
193200 height = { rowHeight }
194201 virtualized = { rowsVirtualized }
@@ -226,6 +233,7 @@ export function TimelineLanes({
226233 onSeek = { onSeek }
227234 />
228235 < div
236+ role = "gridcell"
229237 style = { {
230238 width : trackContentWidth ,
231239 marginLeft : contentGutter , // room for a 0% diamond left of t=0
@@ -502,12 +510,8 @@ export function TimelineLanes({
502510 ) }
503511 </ TimelineClip >
504512 ) ;
505- // Mounted for the track's keyframe clip in BOTH disclosure
506- // states, so the header caret's aria-controls resolves while
507- // collapsed too; collapsed just feeds it no animations, so
508- // the wrapper renders empty. The key is stable across a
509- // multi-drag: without it the passenger branch below remounts
510- // this subtree and interrupts the gesture.
513+ // Keep this shell mounted while collapsed so aria-controls stays valid
514+ // and multi-drag cannot remount the subtree mid-gesture.
511515 const propertyLanes = isTrackKeyframeClip && (
512516 < TimelinePropertyLanes
513517 key = { `${ clipKey } -property-lanes` }
@@ -544,10 +548,7 @@ export function TimelineLanes({
544548 suppressClickRef = { suppressClickRef }
545549 />
546550 ) ;
547- // Keep one keyed top-level child per element. Returning an
548- // array here makes React reconcile the outer array by
549- // position, so a window shift remounts otherwise stable
550- // clip keys and can tear down focus mid-reveal.
551+ // One keyed child prevents window shifts from remounting focused clips.
551552 if ( ! isPassenger ) {
552553 return (
553554 < Fragment key = { clipKey } >
0 commit comments