From 6eb1e0fbde18305509d8190568bdb3edad796ad6 Mon Sep 17 00:00:00 2001 From: HanishKVC Date: Sat, 18 May 2024 22:59:21 +0530 Subject: [PATCH] SimpleChat:JS: bottom of element visible, Set focus to user input As the generated text could be multiple lines and occupy more space that the full scrollable div's vertical space, make the bottom of the last element (which can be such a generated text) in the div visible by scrolling. Ensure that the user input box has focus --- examples/server/public_simplechat/simplechat.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/examples/server/public_simplechat/simplechat.js b/examples/server/public_simplechat/simplechat.js index fed5720c7..d476dd69e 100644 --- a/examples/server/public_simplechat/simplechat.js +++ b/examples/server/public_simplechat/simplechat.js @@ -54,7 +54,7 @@ class SimpleChat { last = entry; } if (last !== undefined) { - last.scrollIntoView(true); + last.scrollIntoView(false); } } @@ -178,6 +178,7 @@ async function handle_submit(inputSystem, inputUser, divChat, apiEP) { if ((apiEP == ApiEP.Completion) && (gbCompletionFreshChatAlways)) { gChat.xchat.length = 0; } + inputUser.focus(); }