Has anyone figured out NavigationStack/NavigationLink/NavigationPath keeps track of selections?

There's some kind of identity being used, but I can't for the life of me figure it out:

gist.github.com/chockenberry/4

And the usual places show lots of developers disabling selections and using other workarounds. The docs don't help much here because the examples are old (NavigationView, StateObject, etc.) and/or use shallow navigation examples.

Follow

@chockenberry having myself gone insane on this, the identity is that of the row value. However with cyclic paths like you have, you need a way to differentiate between screens of the same type and value.

One crude way is to introduce a "level" that increments for each screen, though there's likely more elegant ways to achieve the same thing depending on your setup: gist.github.com/phillipcaudell

@phill Thanks for confirming my suspicions about the row value and how to tweak the objects to get unique hash values. 👍

Sign in to participate in the conversation
The Not So Big Company

The home of The Not So Big Company on Mastodon.