Skip to content
This repository has been archived by the owner on May 10, 2024. It is now read-only.

Commit

Permalink
Fix #8451: Defer toolbar state updates on viewWillAppear by 1 cycle
Browse files Browse the repository at this point in the history
For some reason without this there's a chance iOS lays out the toolbars without any safe area insets
  • Loading branch information
kylehickinson committed Nov 20, 2023
1 parent 215a24a commit aa1843c
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions Sources/Brave/Frontend/Browser/BrowserViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1117,10 +1117,14 @@ public class BrowserViewController: UIViewController {
override public func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
if #available(iOS 17, *) {
// On iOS 17 rotating the device with a full screen modal presented (e.g. Playlist, Tab Tray)
// to landscape then back to portrait does not trigger `traitCollectionDidChange`/`willTransition`/etc
// calls and so the toolbar remains in the wrong state.
updateToolbarStateForTraitCollection(traitCollection)
// Have to defer this to the next cycle to avoid an iOS bug which lays out the toolbars without any
// bottom safe area, resulting in a layout bug.
DispatchQueue.main.async {
// On iOS 17 rotating the device with a full screen modal presented (e.g. Playlist, Tab Tray)
// to landscape then back to portrait does not trigger `traitCollectionDidChange`/`willTransition`/etc
// calls and so the toolbar remains in the wrong state.
self.updateToolbarStateForTraitCollection(self.traitCollection)
}
}
updateToolbarUsingTabManager(tabManager)

Expand Down

0 comments on commit aa1843c

Please sign in to comment.