I used very similar code for another app and the search bar behaves as it should. For some reason, this code below does not work with my current app. Searching online did not yield any answers. The delegate functions aren't the cause of it as when I comment out all their code, it results in the exact same behavior. In fact, when I comment out most of this code below, it results in the same behavior. I don't know why tapping on search destroys my ui. Am I missing something? I must be...
private func configureSearchBar() {
    searchController.searchResultsUpdater = self
    searchController.dimsBackgroundDuringPresentation = false
    searchController.searchBar.showsCancelButton = true
    searchController.searchBar.delegate = self
    searchController.searchBar.isUserInteractionEnabled = true
    definesPresentationContext = true
    searchController.obscuresBackgroundDuringPresentation = false
    searchController.searchBar.translatesAutoresizingMaskIntoConstraints = false
    view.addSubview(searchController.searchBar)
    searchController.searchBar.leftAnchor.constraint(equalTo: view.leftAnchor, constant: 20).isActive = true
    searchController.searchBar.rightAnchor.constraint(equalTo: view.rightAnchor, constant: -20).isActive = true
    searchController.searchBar.heightAnchor.constraint(equalToConstant: 55).isActive = true
    searchController.searchBar.topAnchor.constraint(equalTo: agendaLabel.bottomAnchor, constant: 8).isActive = true
    let color:UIColor = .journeyGold
    let lightGold = color.withAlphaComponent(0.5)
    searchController.searchBar.tintColor = lightGold
    searchController.searchBar.barTintColor = lightGold
    searchController.searchBar.backgroundColor = lightGold
    searchController.searchBar.layer.borderColor = lightGold.cgColor
    navigationItem.hidesSearchBarWhenScrolling = false
    searchController.hidesNavigationBarDuringPresentation = true
    searchController.searchBar.text = ""
    searchController.searchBar.setShowsCancelButton(true, animated: false)
}