     
     func searchBarCancelButtonClicked(_ searchBar: UISearchBar) {
         if let navigationController = navigationController, navigationController.viewControllers.count > 1 {
+            if shouldAnimateSearchBar {
+                searchBar.text = nil
+            }
             navigationController.popViewController(animated: true)
         } else {
             searchBar.endEditing(true)

        self.resultsViewController.view.alpha = visible ? 0 : 1
        self.resultsViewController.view.isHidden = false
        UIView.animate(withDuration: 0.3, animations: animations, completion: completion)
        group.waitInBackgroundAndNotify(on: DispatchQueue.main) {
            self.isAnimatingSearchBarState = false
        }
    }
    
    lazy var resultsViewController: SearchResultsViewController = {

    }()
    
    func setSearchVisible(_ visible: Bool, animated: Bool) {
        let completion = { (finished: Bool) in
            self.resultsViewController.view.isHidden = !visible
            self.isAnimatingSearchBarState = false
        }
        let animations = {
            self.navigationBar.isBarHidingEnabled = true
            self.navigationBar.setNavigationBarPercentHidden(visible ? 1 : 0, underBarViewPercentHidden: 0, extendedViewPercentHidden: 0, animated: false)
            self.navigationBar.isBarHidingEnabled = false
            self.resultsViewController.view.alpha = visible ? 1 : 0
            self.searchBar.setShowsCancelButton(visible, animated: animated)
        }
        guard animated else {
            animations()
