`NavigationLink` in sidebar `List` updates the selection incorrectly

Originator:darren.mo
Number:rdar://FB13447711 Date Originated:2023-12-05
Status:Open Resolved:
Product:SwiftUI Product Version:macOS 14.1.1 (23B81)
Classification:Incorrect/Unexpected Behavior Reproducible:Always
 
I have attached a sample project demonstrating a `NavigationSplitView` with a `List` of `NavigationLink`s in its sidebar. Sometimes, the selection is updated incorrectly.

Reproduction steps:
1. Select the first of the two items.
2. Click the Add Item button.

Expected result: The second of the three items is selected.

Actual result: The third of the three items is selected.

The issue only occurs on macOS and only when using `NavigationLink`. (Even though `NavigationSplitView` still works without the `NavigationLink`, the `NavigationLink` is needed to show the chevron in compact mode, as on iPhone.)

Comments


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!