firefox-ios icon indicating copy to clipboard operation
firefox-ios copied to clipboard

Edit mode misbehaves after changing device orientation to landscape and back to portrait

Open SimonBasca opened this issue 2 years ago • 3 comments

Steps to reproduce

  1. Go to the bookmark panel
  2. Tap "Edit"
  3. Change device orientation to landscape
  4. Change device orientation to portrait

Expected behavior

  • Edit mode should not be dismissed.

Actual behavior

  • Edit mode misbehaves.

Device & build information

  • Device: iPhone 12 Pro (15.5)
  • Build version: 104.0 (14377)

Notes

Attachments:

https://user-images.githubusercontent.com/32130829/181489928-936e81eb-cf92-4291-bfb0-f30237f826a3.mp4

┆Issue is synchronized with this Jira Task

SimonBasca avatar Jul 28 '22 11:07 SimonBasca

The problem is probably that the table view gets reloaded during the orientation change and therefore the editing mode is dismissed. It looks like the current implementation tries to address this problem by reenabling editing mode after the orientation did change.
BookmarksPanel.swift

override func viewWillTransition(to size: CGSize, with coordinator: UIViewControllerTransitionCoordinator) {
    if tableView.isEditing {
        self.tableView.setEditing(false, animated: true)
    }
    super.viewWillTransition(to: size, with: coordinator)
}

However this implementation isn't working because at this point tableView.isEditing is false, even though the table view is in editing mode. Instead we could use the state information.
The following implementation results in the behaviour which is shown in the video:

override func viewWillTransition(to size: CGSize, with coordinator: UIViewControllerTransitionCoordinator) {
    super.viewWillTransition(to: size, with: coordinator)

    coordinator.animate(alongsideTransition: nil) { _ in
        if self.state == .bookmarks(state: .inFolderEditMode) {
            self.tableView.setEditing(true, animated: true)
        }
    }
}

https://user-images.githubusercontent.com/46824694/181503589-1e96efee-da79-4fb8-922e-db2b8e878344.mp4

If that's an appropriate fix for you, I will open a PR with the changes.

finebel avatar Jul 28 '22 12:07 finebel

@finebel I think you are right the tableview is loosing the edit state so the solution you are proposing is appropriate, you can open a PR for it and tag me as a reviewer and thanks for the quick investigation on this issue

yoanarios avatar Jul 28 '22 20:07 yoanarios

➤ Catalin Suciu commented:

Verifying as fixed on v104.0 (14834).

data-sync-user avatar Aug 01 '22 11:08 data-sync-user