I've got an array of items that I use as a source of truth, and I copy that array into another array (filteredItems) and use that to power a NavigationSplitView (on MacOS).
I can sort the items in filteredItems by create date, title, last modified date, forward and reverse, no problem. And I have a text filter field that I can use to filter out items in the filteredItems field and that works great.
So far so good.
But if I reduce the filter text or remove it altogether—thus increasing the number of items in filteredItems or returning it to its original state—weird things happen.
Clicking on items in the navigation portion of the view doesn't bring up the detail view as it did before the reduction and re-adding of items.
After clicking on several of the non-responsive nav items, it freezes up.
I know there are different ways to do this, but my view is set up like this:
NigationSplitView { // filter tool, etc. List { ForEach(ascending ? filteredItems : filteredItems.reversed()) { item in NavigationLink { ItemView(item: item) } label: { // yadda yadda } } }
(ascending is just a boolean state variable)
I know there's not much detail here, but I should be able to change filteredItems as much as I want, right? Or is this construct wrong?