File tree Expand file tree Collapse file tree 1 file changed +11
-5
lines changed
Sources/CodeEditSourceEditor/Search Expand file tree Collapse file tree 1 file changed +11
-5
lines changed Original file line number Diff line number Diff line change @@ -40,10 +40,7 @@ final class SearchViewController: NSViewController {
4040 view. addSubview ( searchBar)
4141 view. addSubview ( childView)
4242
43- searchBarVerticalConstraint = searchBar. topAnchor. constraint (
44- equalTo: view. topAnchor,
45- constant: isShowingSearchBar ? 0 : searchBar. frame. height
46- )
43+ searchBarVerticalConstraint = searchBar. topAnchor. constraint ( equalTo: view. topAnchor)
4744
4845 NSLayoutConstraint . activate ( [
4946 // Constrain search bar
@@ -58,6 +55,15 @@ final class SearchViewController: NSViewController {
5855 childView. trailingAnchor. constraint ( equalTo: view. trailingAnchor)
5956 ] )
6057 }
58+
59+ override func viewWillAppear( ) {
60+ super. viewWillAppear ( )
61+ if isShowingSearchBar { // Update constraints for initial state
62+ showSearchBar ( )
63+ } else {
64+ hideSearchBar ( )
65+ }
66+ }
6167}
6268
6369// MARK: - Toggle Search Bar
@@ -89,7 +95,7 @@ extension SearchViewController {
8995 _ = searchBar? . searchField. resignFirstResponder ( )
9096 withAnimation {
9197 // Update the search bar's top anchor to be equal to it's negative height, hiding it above the view.
92- searchBarVerticalConstraint. constant = - searchBar. frame . height
98+ searchBarVerticalConstraint. constant = - searchBar. fittingSize . height
9399 searchBarVerticalConstraint. isActive = true
94100 }
95101 }
You can’t perform that action at this time.
0 commit comments