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.

(cherry picked from commit 6eb2b2e739)
This commit is contained in:
Joshua Goins
2026-01-17 13:21:05 -05:00
parent ddf272ab2b
commit 82989e7ef2
3 changed files with 24 additions and 7 deletions

View File

@@ -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

View File

@@ -20,8 +20,6 @@ ColumnLayout {
signal resolveResource(string idOrUri, string action)
Layout.fillWidth: true
Layout.alignment: Qt.AlignVCenter
spacing: 0
Item {

View File

@@ -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 {
@@ -334,5 +352,6 @@ QQC2.ScrollView {
userList.headerItem.userListSearchField.text = "";
}
userList.currentIndex = -1;
userList.viewHasSettled = false;
}
}