         return true
     }
     
+    func searchBarTextDidBeginEditing(_ searchBar: UISearchBar) {
+        setSearchResultsVisible(true, animated: true)
+    }
+    
+    func searchBarShouldEndEditing(_ searchBar: UISearchBar) -> Bool {
+        return canSearchBarEndEditing
+    }
+    
+    func searchBarTextDidEndEditing(_ searchBar: UISearchBar) {
+        setSearchResultsVisible(false, animated: true)
+    }
+    
     func searchBar(_ searchBar: UISearchBar, textDidChange searchText: String) {
         search(for: searchBar.text, suggested: false)
     }

        let sucess = { (results: WMFSearchResults, type: WMFSearchType) in
            DispatchQueue.main.async {
                commonCompletion()
                self.areResultsVisible = true
                self.fakeProgressController.finish()
                guard
                    let resultsArray = results.results,

        navigationBar.addUnderNavigationBarView(searchBarContainerView)
        updateLanguageBarVisibility()
        navigationBar.isInteractiveHidingEnabled  = false
        view.bringSubview(toFront: resultsViewController.view)
    }
    
    var canSearchBarEndEditing: Bool = false
    override func viewWillAppear(_ animated: Bool) {
        super.viewWillAppear(animated)
        canSearchBarEndEditing = false
        navigationBar.isBarHidingEnabled = true
        navigationBar.setNavigationBarPercentHidden(1, underBarViewPercentHidden: 0, extendedViewPercentHidden: 0, animated: animated && shouldAnimateSearchBar, additionalAnimations: {
            self.canSearchBarEndEditing = true
            self.updateScrollViewInsets()
        })
        navigationBar.isBarHidingEnabled = false
        searchBar.setShowsCancelButton(true, animated: animated && shouldAnimateSearchBar)
        if animated && shouldBecomeFirstResponder {
