Repository navigation
Bugfix: Preserve ForEach TabView State - #533
Merged
Merged
Conversation
Member
Author
|
Hi @marcprux, thanks for merging my other PRs. However, after merging the latest main into my temporary branch, I noticed this small Android regression. It seems related to #500 and affects The fix is tiny and the PR includes a small repro plus before/after screenshots. If possible, it would be great to get this into the next skip-ui release as well. Thanks! 😊 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR fixes a
TabViewstate reset on Android when tab content is produced by an unrolledForEach.This appears to be a regression after #500.
ForEachIdentityModifierkeyed the rendered subtree with both the rememberedForEachnamespace and the element identity. InTabView, content can leave and re-enter the composition, recreating that namespace and causing stable tab content to remount.This change keeps the namespace for parent container child-key calculation, but uses only the stable element identity for the modifier's inner render key.
To reproduce:
Before:

After:

=> As you can see, before this change the
instanceIDstate changes every time the tab is revisited, because the tab content is remounted. After this change, theinstanceIDremains stable when switching away from a tab and back.Thank you for contributing to the Skip project! Please review the contribution guide at https://skip.dev/docs/contributing/ for advice and guidance on making high-quality PRs.
Use this space to describe your change and add any labels (bug, enhancement, documentation, etc.) to help categorize your contribution.
Skip Pull Request Checklist:
swift test