From 6eb2b2e739dc634ef892423a624fcfc9b4a3d036 Mon Sep 17 00:00:00 2001 From: Joshua Goins Date: Sat, 17 Jan 2026 13:21:05 -0500 Subject: [PATCH] Add hack to fix room sidebar not sticking to the top This is similar to the TimelineView hacks, but this time its the header item that's changing height as our room topics and such wrap. --- src/libneochat/qml/GroupChatDrawerHeader.qml | 4 ++-- src/roominfo/DirectChatDrawerHeader.qml | 2 -- src/roominfo/RoomInformation.qml | 25 +++++++++++++++++--- 3 files changed, 24 insertions(+), 7 deletions(-) diff --git a/src/libneochat/qml/GroupChatDrawerHeader.qml b/src/libneochat/qml/GroupChatDrawerHeader.qml index 6c87c33a6..61766d3f7 100644 --- a/src/libneochat/qml/GroupChatDrawerHeader.qml +++ b/src/libneochat/qml/GroupChatDrawerHeader.qml @@ -22,9 +22,9 @@ ColumnLayout { /** * @brief The canonical alias of the room, if it exists. Otherwise falls back to the first available alias. */ - readonly property var roomAlias: room.aliases[0] + readonly property string roomAlias: room?.aliases[0] ?? "" - Layout.fillWidth: true + spacing: 0 RowLayout { Layout.fillWidth: true diff --git a/src/roominfo/DirectChatDrawerHeader.qml b/src/roominfo/DirectChatDrawerHeader.qml index bca480e1f..edcd584e6 100644 --- a/src/roominfo/DirectChatDrawerHeader.qml +++ b/src/roominfo/DirectChatDrawerHeader.qml @@ -21,8 +21,6 @@ ColumnLayout { signal resolveResource(string idOrUri, string action) - Layout.fillWidth: true - Layout.alignment: Qt.AlignVCenter spacing: 0 Item { diff --git a/src/roominfo/RoomInformation.qml b/src/roominfo/RoomInformation.qml index 244cdecdf..710c7f198 100644 --- a/src/roominfo/RoomInformation.qml +++ b/src/roominfo/RoomInformation.qml @@ -48,6 +48,10 @@ QQC2.ScrollView { ListView { id: userList + + // Used to determine if the view has settled and should stop perfoming the hack + property bool viewHasSettled: false + header: ColumnLayout { id: columnLayout @@ -56,15 +60,29 @@ QQC2.ScrollView { spacing: 0 width: ListView.view ? ListView.view.width - ListView.view.leftMargin - ListView.view.rightMargin : 0 + // HACK: Resettle this ListView while our labels wrap themselves. ListView doesn't do this automatically. + // We use the Timer to determine when its done internally reshuffling, so we don't accidentally send you to the top if you actually scrolled down. + onHeightChanged: { + if (!userList.viewHasSettled) { + userList.positionViewAtBeginning(); + hackTimer.restart(); + } + } + + Timer { + id: hackTimer + + // The internal wrapping and height changes happen quickly, so we don't need a long interval here + interval: 1 + onTriggered: userList.viewHasSettled = true + } + Loader { active: true Layout.fillWidth: true Layout.topMargin: Kirigami.Units.smallSpacing visible: !root.room.isSpace sourceComponent: root.room.isDirectChat() ? directChatDrawerHeader : groupChatDrawerHeader - onItemChanged: if (item) { - userList.positionViewAtBeginning(); - } } Kirigami.ListSectionHeader { @@ -322,5 +340,6 @@ QQC2.ScrollView { userList.headerItem.userListSearchField.text = ""; } userList.currentIndex = -1; + userList.viewHasSettled = false; } }