Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reordering to top is broken on iOS 13.3, Xcode 11.3.1 #68

Open
anton-plebanovich opened this issue Jan 18, 2020 · 12 comments
Open

Reordering to top is broken on iOS 13.3, Xcode 11.3.1 #68

anton-plebanovich opened this issue Jan 18, 2020 · 12 comments

Comments

@anton-plebanovich
Copy link
Contributor

So spend half a day today trying to figure out and maybe fix a bug with cell reordering when you try to reorder a cell to the top with a scrolling involved. Basically all you need to do is to scroll at least a little bit down and then try to reorder cell to the very top. There'll be an animation glitch on the last cell reordering. It especially obvious for grouped table views. I used iPhone SE for tests.

1

I tried to force layout first and contentOffset restore after to prevent jumps but while I almost fixed a jump glitch cells content and sizes started to glitch so no idea how to fix this one.

@anton-plebanovich
Copy link
Contributor Author

Well at least found a workaround for now - just do not animate last cell move. In ReorderController+DestinationRow.swift updateDestinationRow() use this:

        if #available(iOS 13.0, *), newContext.destinationRow == IndexPath(row: 0, section: 0) {
            tableView.reloadData()
        } else {
            tableView.moveRow(at: context.destinationRow, to: newContext.destinationRow)
        }

Not sure, though, about the concrete iOS 13 version this bug was introduced.

@anton-plebanovich
Copy link
Contributor Author

anton-plebanovich commented Jan 18, 2020

Reproduces on iOS 13.2.2 and iOS 13.3

@BrentonBeltrami
Copy link

I am running into this issue as well & added the fix you provided but it created a new issue where it makes all other cells I scroll over invisible. Do you know what might be causing that? Thank you

@anton-plebanovich
Copy link
Contributor Author

anton-plebanovich commented Feb 1, 2020

@dontknowwhatiamdoin try to replace original lines:

        tableView.beginUpdates()
        tableView.deleteRows(at: [context.destinationRow], with: .fade)
        tableView.insertRows(at: [newContext.destinationRow], with: .fade)
        tableView.endUpdates()

with those:

        if #available(iOS 13.0, *), newContext.destinationRow == IndexPath(row: 0, section: 0) {
            tableView.reloadData()
        } else {
            tableView.beginUpdates()
            tableView.deleteRows(at: [context.destinationRow], with: .fade)
            tableView.insertRows(at: [newContext.destinationRow], with: .fade)
            tableView.endUpdates()
        }

Overall, thise fix shouldn't affect anything except reordering to the first row.

@BrentonBeltrami
Copy link

Thank you, this worked for me.

@Ant-Adis
Copy link

@anton-plebanovich That works great, thanks :D

@andreigubceac
Copy link

andreigubceac commented Apr 30, 2020

@anton-plebanovich , why not just tableView.moveRow(at: sourceIndexPath, to: destinationIndexPath)?

@anton-plebanovich
Copy link
Contributor Author

@andreigubceac I am not the author so can't be sure, just left that as is.

@DantePuglisi
Copy link

@anton-plebanovich It's not working anymore (iOS 13.6) even when using the fixes here. Does anyone have any updated workaround?

@Saulenco
Copy link

Saulenco commented Sep 9, 2020

have the same issue , and this workaround does not fix the issue

@mohdtahir-kiwi
Copy link

have the same issue, is it fix?

@Saulenco
Copy link

Hi guys found an alternative. Check full answer here

tableView.dragInteractionEnabled = true
tableView.dragDelegate = self
tableView.dropDelegate = self

func tableView(_ tableView: UITableView, moveRowAt sourceIndexPath: IndexPath, to destinationIndexPath: IndexPath) { }

extension TableView: UITableViewDragDelegate {
func tableView(_ tableView: UITableView, itemsForBeginning session: UIDragSession, at indexPath: IndexPath) -> [UIDragItem] {
        return [UIDragItem(itemProvider: NSItemProvider())]
    }
} 

extension TableView: UITableViewDropDelegate {
    func tableView(_ tableView: UITableView, dropSessionDidUpdate session: UIDropSession, withDestinationIndexPath destinationIndexPath: IndexPath?) -> UITableViewDropProposal {

        if session.localDragSession != nil { // Drag originated from the same app.
            return UITableViewDropProposal(operation: .move, intent: .insertAtDestinationIndexPath)
        }

        return UITableViewDropProposal(operation: .cancel, intent: .unspecified)
    }

    func tableView(_ tableView: UITableView, performDropWith coordinator: UITableViewDropCoordinator) {
    }
}

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

No branches or pull requests

7 participants