From 71468f02f25cbd51c418ecba9286ea8d7a121982 Mon Sep 17 00:00:00 2001 From: Blake Oliver Date: Mon, 20 Apr 2026 17:58:53 -0600 Subject: [PATCH] Scroll to bottom of the lazyVStack when the keyboard opens / input field gains focus in dm and buffer views --- KDChat/Views/ChatBufferView.swift | 5 +++++ KDChat/Views/DMConversationView.swift | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/KDChat/Views/ChatBufferView.swift b/KDChat/Views/ChatBufferView.swift index b0c6baf..5f42f31 100644 --- a/KDChat/Views/ChatBufferView.swift +++ b/KDChat/Views/ChatBufferView.swift @@ -38,6 +38,11 @@ struct ChatBufferView: View { } .padding() } + .onChange(of: isInputFocused) { _, focused in + if focused, let last = messages.last { + proxy.scrollTo(last.persistentModelID, anchor: .bottom) + } + } .onChange(of: messages.count) { guard let last = messages.last, last.sessionId == manager.sessionId else { return } Task { @MainActor in diff --git a/KDChat/Views/DMConversationView.swift b/KDChat/Views/DMConversationView.swift index bf56813..20e4f00 100644 --- a/KDChat/Views/DMConversationView.swift +++ b/KDChat/Views/DMConversationView.swift @@ -34,6 +34,11 @@ struct DMConversationView: View { } .padding() } + .onChange(of: isInputFocused) { _, focused in + if focused, let last = messages.last { + proxy.scrollTo(last.persistentModelID, anchor: .bottom) + } + } .onChange(of: messages.count) { guard let last = messages.last, last.sessionId == manager.sessionId else { return } Task { @MainActor in