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.
This commit is contained in:
Joshua Goins
2026-01-17 13:21:05 -05:00
parent be89362fdd
commit 6eb2b2e739
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. * @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 { RowLayout {
Layout.fillWidth: true Layout.fillWidth: true

View File

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

View File

@@ -48,6 +48,10 @@ QQC2.ScrollView {
ListView { ListView {
id: userList id: userList
// Used to determine if the view has settled and should stop perfoming the hack
property bool viewHasSettled: false
header: ColumnLayout { header: ColumnLayout {
id: columnLayout id: columnLayout
@@ -56,15 +60,29 @@ QQC2.ScrollView {
spacing: 0 spacing: 0
width: ListView.view ? ListView.view.width - ListView.view.leftMargin - ListView.view.rightMargin : 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 { Loader {
active: true active: true
Layout.fillWidth: true Layout.fillWidth: true
Layout.topMargin: Kirigami.Units.smallSpacing Layout.topMargin: Kirigami.Units.smallSpacing
visible: !root.room.isSpace visible: !root.room.isSpace
sourceComponent: root.room.isDirectChat() ? directChatDrawerHeader : groupChatDrawerHeader sourceComponent: root.room.isDirectChat() ? directChatDrawerHeader : groupChatDrawerHeader
onItemChanged: if (item) {
userList.positionViewAtBeginning();
}
} }
Kirigami.ListSectionHeader { Kirigami.ListSectionHeader {
@@ -322,5 +340,6 @@ QQC2.ScrollView {
userList.headerItem.userListSearchField.text = ""; userList.headerItem.userListSearchField.text = "";
} }
userList.currentIndex = -1; userList.currentIndex = -1;
userList.viewHasSettled = false;
} }
} }