Fix room list search bar focus glitches (#2112)

* Fixes #2112 - Room list search bar focus glitches

* Address PR comments
This commit is contained in:
Stefan Ceriu
2023-11-17 18:08:29 +02:00
committed by GitHub
parent d245a4f158
commit f717c7dba4
4 changed files with 24 additions and 6 deletions
@@ -22,10 +22,20 @@ struct HomeScreenRoomList: View {
@ObservedObject var context: HomeScreenViewModel.Context
var body: some View {
content
filteredContent
.onChange(of: isSearchFieldFocused) { context.isSearchFieldFocused = $0 }
}
@ViewBuilder
private var filteredContent: some View {
// Hide the room list when the search bar is focused but the query is empty
// This works hand in hand with the room list service layer filtering and
// avoids glitches when focusing the search bar
if !context.viewState.shouldHideRoomList {
content
}
}
@ViewBuilder
private var content: some View {
ForEach(context.viewState.visibleRooms) { room in