List selection (UI) does not update when selection is changed programmatically

I have a List that's embedded in an NSHostingView with an @Observable data connecting the two worlds.

I can select an item in the list with the mouse and use arrow keys to change the selection and it is updated properly on the AppKit side.

However, when I change the selection from the AppKit side, the selection disappears in the List, even though an .onChange does get triggered with the right new selection ID. But the UI no longer displays it.

I created a simple NSHostView example and that works. But the same method does not work in a more complex layout where the view is much deeper in the hierarchy.

Something is happening because the List loses its last selection highlight.

What's the best approach to tracking down why the List UI is not updating the selection?

I am trying to avoid going back to using NSTableView and doing it all manually, but I really need to selection to be able to change.

Thank you.

Answered by Frameworks Engineer in 892611022

Hey!

That shouldn't happen. Could you please file a feedback, (here are some great tips how to file a feedback), ideally with steps to reproduce? Small reproducer would be ideal but full project or even just the binary should work here with what actions trigger the issue.

Thank you!

Hey!

That shouldn't happen. Could you please file a feedback, (here are some great tips how to file a feedback), ideally with steps to reproduce? Small reproducer would be ideal but full project or even just the binary should work here with what actions trigger the issue.

Thank you!

List selection (UI) does not update when selection is changed programmatically
 
 
Q