Skip to content
This repository has been archived by the owner on Nov 4, 2022. It is now read-only.

ASCollectionView wrapped in NavigationView causing bottom cells on screen to reload after dismissing keyboard #190

Open
skunkworker opened this issue Nov 18, 2020 · 4 comments

Comments

@skunkworker
Copy link
Contributor

Describe the bug
When a ASCollectionView is wrapped inside of a NavigationView and you present a Sheet View with an editable field. If you are focused on the editable field and then dismiss the view, which dismisses the keyboard, the last few items are being "reloaded" with an animation from the left.

To Reproduce
This small test app reproduces this bug.
https://github.com/skunkworker/ascollection-view-bug-testapp
Click the "+" at the top, then click "Close" or "Save"

Expected behaviour
The sheet should be dismissed without any of the cell items refreshing.

Screenshots

The animation shows that the last cell loads in when it should be fully loaded at this stage of the keyboard dismissal.

Video included in bug reproduction repository above.
Screen Shot 2020-11-17 at 11 55 31 PM
Screen Shot 2020-11-17 at 11 55 36 PM
Screen Shot 2020-11-17 at 11 55 43 PM
Screen Shot 2020-11-17 at 11 55 49 PM

Xcode Version:

  • 12.2

Simulator, Device, Both?

  • iPhone 12 Simulator 14.2
@skunkworker
Copy link
Contributor Author

skunkworker commented Nov 18, 2020

This issue appears to be very odd. I am logging each of the cells with their number every time they appear and disappear. Sometimes the sheet can be presented without the cells disappearing, but the cells that disappear and reappear when the keyboard is brought up always show the issue.

Other times those same cells are never disappeared/appeared and the issue does not show up.

@skunkworker
Copy link
Contributor Author

I got around this bug by changing the itemSize to absolute instead of estimated. I think this may be because the estimated size changes for the cells that are being blocked by the keyboard. It's hackish but it works.

                return ASCollectionLayoutSection
                {
                    let itemSize = NSCollectionLayoutSize(
                        widthDimension: .fractionalWidth(1.0),
                        heightDimension: .absolute(60))
                    let item = NSCollectionLayoutItem(layoutSize: itemSize)

@apptekstudios
Copy link
Owner

I think this might have to do with SwiftUI's new keyboard avoidance behaviour. I am curious if this still happens when using the v1.8.0 branch? Otherwise, it seems that the cells' frames are being set within an animation block, which is odd given this is managed by UICollectionView outside of our control.

@skunkworker
Copy link
Contributor Author

@apptekstudios I just tested this on v1.8.0WIP and I'm still seeing the original behavior.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants