-
Notifications
You must be signed in to change notification settings - Fork 0
Tap tab button again to scroll to top #1070
Conversation
a536e4f
to
dd33b38
Compare
ForEach(deck.indices, id: \.self) { index in | ||
let card = deck[index] | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Apparently there are problems with using enumerated()
this way that can result in BAD_ACCESS
errors, see: https://stackoverflow.com/a/63145650
Using indices
is apparently safer and seems equally readable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One note, otherwise LGTM
@@ -35,6 +37,7 @@ struct EntryListView: View { | |||
onLink: onLink | |||
) | |||
} | |||
.id(idx) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is likely to cause issues, as ids are meant to be stable identifiers tied to records. If the record changed but had same index, or if the same record changed index, we might see view invalidation bugs.
Should replace with a stable record ID of some sort.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good note, I've ditched this approach and inserted an EmptyView
with a stable .id()
at the top instead. This is easier to read as well imo, so win-win.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Fixes #991
Pretty simple, using
ScrollReaderView
for iOS 16 support but we could clean this up a little using the newer iOS 17 APIs down the line.Screen.Recording.2024-01-15.at.4.34.17.pm.mov
Screen.Recording.2024-01-15.at.6.31.00.pm.mov