mirror of
https://git.mills.io/saltyim/saltyim.git
synced 2024-06-28 17:51:04 +00:00
auto scroll to last chat message
This commit is contained in:
parent
8e8f8ec728
commit
f5aaf48ebc
@ -1,8 +1,6 @@
|
||||
package components
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/maxence-charriere/go-app/v9/pkg/app"
|
||||
"github.com/mlctrez/goapp-mdc/pkg/bar"
|
||||
"github.com/mlctrez/goapp-mdc/pkg/base"
|
||||
@ -77,7 +75,6 @@ func (h *Hello) Render() app.UI {
|
||||
}),
|
||||
),
|
||||
app.Form().OnSubmit(func(ctx app.Context, e app.Event) {
|
||||
fmt.Println("app.Form().OnSubmit()")
|
||||
e.PreventDefault()
|
||||
h.messages = append(h.messages, h.chatInput.Value)
|
||||
h.chatInput.Value = ""
|
||||
@ -86,6 +83,11 @@ func (h *Hello) Render() app.UI {
|
||||
chatInputValue := h.JsUtil.JsValueAtPath(h.chatInput.Id + "-input")
|
||||
chatInputValue.Set("value", "")
|
||||
chatInputValue.Call("focus")
|
||||
|
||||
ctx.Defer(func(context app.Context) {
|
||||
chatBoxDiv := h.JsUtil.JsValueAtPath("chatbox")
|
||||
chatBoxDiv.Set("scrollTop", chatBoxDiv.Get("scrollHeight"))
|
||||
})
|
||||
}).Body(
|
||||
h.chatInput,
|
||||
icon.MISend.Button().ID("chat-send"),
|
||||
|
Loading…
Reference in New Issue
Block a user