Skip to content
This repository was archived by the owner on Sep 11, 2024. It is now read-only.

Commit 839851c

Browse files
committed
Fix bug where 'show more' sometimes did nothing
a3a1e2e added the padding to maxTilesPx which was confusing the calculation of whether we should be showing the 'show more' button or the 'show less' button. Hopefully this fixes the issue without undoing fixes from #4964 or the above commit by adding the padding in all cased in `get padding()`.
1 parent 225c31e commit 839851c

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

src/components/views/rooms/RoomSublist2.tsx

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -127,11 +127,17 @@ export default class RoomSublist2 extends React.Component<IProps, IState> {
127127
private get padding() {
128128
let padding = RESIZE_HANDLE_HEIGHT;
129129
// this is used for calculating the max height of the whole container,
130-
// and takes into account whether there should be room reserved for the show less button
131-
// when fully expanded. We cannot check against the layout's defaultVisible tile count
130+
// and takes into account whether there should be room reserved for the show more/less button
131+
// when fully expanded. We can't rely purely on the layout's defaultVisible tile count
132132
// because there are conditions in which we need to know that the 'show more' button
133133
// is present while well under the default tile limit.
134-
if (this.numTiles > this.numVisibleTiles) {
134+
const needsShowMore = this.numTiles > this.numVisibleTiles;
135+
136+
// ...but also check this or we'll miss if the section is expanded and we need a
137+
// 'show less'
138+
const needsShowLess = this.numTiles > this.layout.defaultVisibleTiles;
139+
140+
if (needsShowMore || needsShowLess) {
135141
padding += SHOW_N_BUTTON_HEIGHT;
136142
}
137143
return padding;
@@ -621,16 +627,13 @@ export default class RoomSublist2 extends React.Component<IProps, IState> {
621627
'mx_RoomSublist2_showNButton': true,
622628
});
623629

624-
if (this.numTiles > this.layout.defaultVisibleTiles) {
625-
maxTilesPx += SHOW_N_BUTTON_HEIGHT;
626-
}
627-
628630
// If we're hiding rooms, show a 'show more' button to the user. This button
629631
// floats above the resize handle, if we have one present. If the user has all
630632
// tiles visible, it becomes 'show less'.
631633
let showNButton = null;
632634

633635
if (maxTilesPx > this.state.height) {
636+
// the height of all the tiles is greater than the section height: we need a 'show more' button
634637
const nonPaddedHeight = this.state.height - RESIZE_HANDLE_HEIGHT - SHOW_N_BUTTON_HEIGHT;
635638
const amountFullyShown = Math.floor(nonPaddedHeight / this.layout.tileHeight);
636639
const numMissing = this.numTiles - amountFullyShown;

0 commit comments

Comments
 (0)