Sibling ForEach blocks with the same IDs share Compose keys since #533
Maintainers usually reply within 4 days
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 22/100
Research direction
The bug is in how unrolled ForEach content gets Compose keys, so start from the key computation that uses currentCompositeKeyHash and the ForEach identity namespace, and from the rememberSaveable path that restores state under that key. Reproduce with two sibling ForEach blocks that share IDs, then check whether two Row(id: 1) views end up with the same key. Done means siblings get distinct keys and the TabView re-entry case still keeps its state. Pick the discriminator with a maintainer first, since the reporter's approach is still open.
Written by the indexing model from the issue text.
Description
Since #533, unrolled ForEach content is keyed by identity alone. That fixed the TabView remount, but two sibling ForEach blocks with the same IDs now get the same Compose keys:
struct Row: View {
let list: String
let id: Int
@State var taps = 0
var body: some View {
Text("\(list) \(id): \(taps)").onTapGesture { taps += 1 }
}
}
VStack {
ForEach([1, 2], id: \.self) { Row(list: "favorites", id: $0) }
ForEach([1, 2, 3], id: \.self) { Row(list: "all", id: $0) }
}
Both Row(id: 1) views get the same currentCompositeKeyHash, so rememberSaveable restores them under one key and a row can take the other block's state. In a Skip Fuse app (favorites and recents of the same items in one LazyVStack), this trapped in syncState on a null StateSupport after scrolling, on an Android 16 emulator with skip-ui 1.62.0.
Keying by (ForEachIdentityNamespace, identity), as before #533, separates siblings, but the namespace is remembered, so it changes on re-entry, which is the TabView case. A discriminator that survives re-entry, such as the ForEach's position among its parent's children combined with the identity, would fix both. Happy to open a PR once you've picked an approach.
Found with Claude Code while porting a SwiftUI app to Android with Skip Fuse.
- Dominant language
- Swift
- Stars
- 334
- Forks
- 95
- Avg merge
- 2d 10h
- Merged PRs (30d)
- 8
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from skiptools/skip-ui
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Maintainers usually reply within 4 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 80/100
Maintainers usually reply within 4 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
Maintainers usually reply within 4 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
Maintainers usually reply within 4 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
Maintainers usually reply within 4 days
All issues in skiptools/skip-ui
Similar issues
-
AndroidAssetManager(env:peer:) in AssetURLProtocol.swift doesn't compile for Android on the Swift nightlyPossibly taken A pull request linked to this issue is open or already merged. Open
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
good first issue help wanted
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
erkamyaman/unslop-anything#579 ·
Maintainers usually reply within 1 day
-
good first issue help wanted
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
erkamyaman/rust-anything#1311 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day
-
bug priority:low status:queued
Difficulty 2/5 1-3 hours Newbie friendliness 83/100
Maintainers usually reply within 1 day