I am trying to port an applicaiton I am working on for MacOS to use the new NavigationSplitViews.
Two issues have come up:
- When run I get this message repeatedly:
"Update NavigationAuthority bound selection tried to update multiple times per frame."
- The following is the heart of the navigation I am using (simplified). If my content is a TextEditor(...) it works correctly. If I use the NSTextView/Representable - CustomTextEdit in the code below it doesn't work. It did/does work with the older style of NavigationLinks.
The editor is initialized before any items in the list are clicked on and are not updated when a different row in the list is clicked. BUT. If I save the document, and reopen the saved, the clicked on row is presented. So, the issue is the NSTextView is not getting updated. Any suggestions would be greatly apprecaited.
Also, the Text view in the detail section is being updated corrected when rows in the sidebarlist are clicked on.
EDITED: I can see the $document.model.selected is not being updated on clicking/selecting a row.
struct ContentView: View {
@Binding var document: HermesDocument
var body: some View {
NavigationSplitView(columnVisibility: $columnVisible) {
if let children = document.model.sidebar.children {
List(children, id: \.self, children: \.children, selection: $document.model.selected) { sidebar in
Label(sidebar.name, systemImage: SFSymbolsModel.icon[sidebar.iconName] ?? "questionmark")
}
.navigationSplitViewColumnWidth(min: 200, ideal: 250)
}
} content: {
CustomTextEditor(text: $document.model.selected.text)
.padding(.all)
.frame(width: 600.0)
} detail: {
VStack {
Text(document.model.selected.text?.string ?? "empty")
.padding(.all)
.frame(width: 200.0)
}
}
.navigationSplitViewStyle(.prominentDetail)
}
}