ASCollectionView icon indicating copy to clipboard operation
ASCollectionView copied to clipboard

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

Open skunkworker opened this issue 3 years ago • 4 comments

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 avatar Nov 18 '20 06:11 skunkworker

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 avatar Nov 18 '20 07:11 skunkworker

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)

skunkworker avatar Dec 12 '20 21:12 skunkworker

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.

apptekstudios avatar Dec 15 '20 01:12 apptekstudios

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

skunkworker avatar Dec 19 '20 20:12 skunkworker