Scrolling Table with children in SwiftUI for macOS app

How do I scroll to a row and select it when it is part of collapsed rows in Table

ScrollViewReader { scrollViewProxy in
	Table([node], children: \.children, selection: $selectedNodeID) {
		TableColumn("Key") { Text($0.key) }
		TableColumn("Value") { Text($0.val) }
	}
	.onChange(of: selectedNodeID) { _, newValue in
		withAnimation {
			scrollViewProxy.scrollTo(newValue)
		}
	}
}

The code above works well for the rows that are expanded or at the root level. However, for the rows that are not yet expanded the code above does nothing. How can I update the code so that it scrolls to a row that has not materialized yet.

Info:

  • This is a macOS app
  • I am on macOS 15.1.1 with Xcode 16.1 and the minimum target of the app is macOS 15
Scrolling Table with children in SwiftUI for macOS app
 
 
Q