diff --git a/dist/index.css b/dist/index.css index 5c429a0d..05b158c4 100644 --- a/dist/index.css +++ b/dist/index.css @@ -60,7 +60,7 @@ } [showingobjects][chatvisible][chatopen] .thread-view { top: unset; - bottom: var(--control-height); + bottom: calc(var(--control-height) + var(--safe-area-bottom)); width: 100%; height: var(--split-thread-height); padding: 0px; diff --git a/dist/index.js b/dist/index.js index 2c1a7df3..18b0aa2d 100644 --- a/dist/index.js +++ b/dist/index.js @@ -1331,6 +1331,9 @@ [isShowingObjects, isShowingChatInSplit], () => isShowingObjects.value == false || isShowingChatInSplit.value == true ); + isShowingObjects.subscribeSilent(() => { + setTimeout(() => scrollToChat("instant"), 1); + }); var newChatName = new State(""); var cannotCreateChat = createProxyState( [newChatName], @@ -1348,7 +1351,10 @@ function selectChat(chat) { selectedChat.value = chat; chat.hasUnreadMessages.value = false; - document.getElementById("message-tab")?.scrollIntoView(); + scrollToChat(); + } + function scrollToChat(behavior = "smooth") { + document.getElementById("message-tab")?.scrollIntoView({ behavior }); } function toggleObjects() { isShowingObjects.value = !isShowingObjects.value; diff --git a/src/Model/model.ts b/src/Model/model.ts index c2e43e36..c06cbab4 100644 --- a/src/Model/model.ts +++ b/src/Model/model.ts @@ -223,6 +223,9 @@ export const isChatVisible = React.createProxyState( [isShowingObjects, isShowingChatInSplit], () => isShowingObjects.value == false || isShowingChatInSplit.value == true ); +isShowingObjects.subscribeSilent(() => { + setTimeout(() => scrollToChat("instant"), 1); +}); export const newChatName = new React.State(""); @@ -246,7 +249,11 @@ export function closeChatView() { export function selectChat(chat: Chat) { selectedChat.value = chat; chat.hasUnreadMessages.value = false; - document.getElementById("message-tab")?.scrollIntoView(); + scrollToChat(); +} + +export function scrollToChat(behavior: ScrollBehavior = "smooth") { + document.getElementById("message-tab")?.scrollIntoView({ behavior }); } export function toggleObjects() {