1
0
Fork 0
forked from Mirrors/gomuks

web/roomlist: scroll entry to view when switching rooms

This commit is contained in:
Tulir Asokan 2024-11-07 17:53:53 +01:00
parent c5452a570e
commit 3df80686c4
2 changed files with 7 additions and 1 deletions

View file

@ -56,6 +56,10 @@ class ContextFields implements MainScreenContextFields {
} }
this.client.store.activeRoomID = room?.roomID this.client.store.activeRoomID = room?.roomID
this.keybindings.activeRoom = room this.keybindings.activeRoom = room
if (roomID) {
document.querySelector(`div.room-entry[data-room-id="${CSS.escape(roomID)}"]`)
?.scrollIntoView({ block: "nearest" })
}
} }
clickRoom = (evt: React.MouseEvent) => { clickRoom = (evt: React.MouseEvent) => {

View file

@ -49,7 +49,9 @@ export const ReplyIDBody = ({ room, eventID, isThread }: ReplyIDBodyProps) => {
} }
const onClickReply = (evt: React.MouseEvent) => { const onClickReply = (evt: React.MouseEvent) => {
const targetEvt = document.querySelector(`div[data-event-id="${evt.currentTarget.getAttribute("data-reply-to")}"]`) const targetEvt = document.querySelector(
`div[data-event-id="${CSS.escape(evt.currentTarget.getAttribute("data-reply-to") ?? "")}"]`,
)
if (targetEvt) { if (targetEvt) {
targetEvt.scrollIntoView({ targetEvt.scrollIntoView({
block: "center", block: "center",