mirror of https://github.com/vector-im/riot-web
Merge pull request #4786 from matrix-org/travis/room-list/show-n-reliability
Fix show less/more button occluding the list automaticallypull/21833/head
commit
b857c9d199
|
@ -41,6 +41,11 @@ import { ListAlgorithm, SortAlgorithm } from "../../../stores/room-list/algorith
|
||||||
* warning disappears. *
|
* warning disappears. *
|
||||||
*******************************************************************/
|
*******************************************************************/
|
||||||
|
|
||||||
|
const SHOW_N_BUTTON_HEIGHT = 32; // As defined by CSS
|
||||||
|
const RESIZE_HANDLE_HEIGHT = 4; // As defined by CSS
|
||||||
|
|
||||||
|
const MAX_PADDING_HEIGHT = SHOW_N_BUTTON_HEIGHT + RESIZE_HANDLE_HEIGHT;
|
||||||
|
|
||||||
interface IProps {
|
interface IProps {
|
||||||
forRooms: boolean;
|
forRooms: boolean;
|
||||||
rooms?: Room[];
|
rooms?: Room[];
|
||||||
|
@ -105,7 +110,7 @@ export default class RoomSublist2 extends React.Component<IProps, IState> {
|
||||||
};
|
};
|
||||||
|
|
||||||
private onShowAllClick = () => {
|
private onShowAllClick = () => {
|
||||||
this.props.layout.visibleTiles = this.numTiles;
|
this.props.layout.visibleTiles = this.props.layout.tilesWithPadding(this.numTiles, MAX_PADDING_HEIGHT);
|
||||||
this.forceUpdate(); // because the layout doesn't trigger a re-render
|
this.forceUpdate(); // because the layout doesn't trigger a re-render
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -393,18 +398,16 @@ export default class RoomSublist2 extends React.Component<IProps, IState> {
|
||||||
// goes backwards and can become wildly incorrect (visibleTiles says 18 when there's
|
// goes backwards and can become wildly incorrect (visibleTiles says 18 when there's
|
||||||
// only mathematically 7 possible).
|
// only mathematically 7 possible).
|
||||||
|
|
||||||
const showMoreHeight = 32; // As defined by CSS
|
|
||||||
const resizeHandleHeight = 4; // As defined by CSS
|
|
||||||
|
|
||||||
// The padding is variable though, so figure out what we need padding for.
|
// The padding is variable though, so figure out what we need padding for.
|
||||||
let padding = 0;
|
let padding = 0;
|
||||||
if (showNButton) padding += showMoreHeight;
|
if (showNButton) padding += SHOW_N_BUTTON_HEIGHT;
|
||||||
if (handles.length > 0) padding += resizeHandleHeight;
|
padding += RESIZE_HANDLE_HEIGHT; // always append the handle height
|
||||||
|
|
||||||
const minTilesPx = layout.calculateTilesToPixelsMin(tiles.length, layout.minVisibleTiles, padding);
|
const relativeTiles = layout.tilesWithPadding(tiles.length, padding);
|
||||||
|
const minTilesPx = layout.calculateTilesToPixelsMin(relativeTiles, layout.minVisibleTiles, padding);
|
||||||
const maxTilesPx = layout.tilesToPixelsWithPadding(tiles.length, padding);
|
const maxTilesPx = layout.tilesToPixelsWithPadding(tiles.length, padding);
|
||||||
const tilesWithoutPadding = Math.min(tiles.length, layout.visibleTiles);
|
const tilesWithoutPadding = Math.min(relativeTiles, layout.visibleTiles);
|
||||||
const tilesPx = layout.calculateTilesToPixelsMin(tiles.length, tilesWithoutPadding, padding);
|
const tilesPx = layout.calculateTilesToPixelsMin(relativeTiles, tilesWithoutPadding, padding);
|
||||||
|
|
||||||
content = (
|
content = (
|
||||||
<ResizableBox
|
<ResizableBox
|
||||||
|
|
|
@ -92,8 +92,12 @@ export class ListLayout {
|
||||||
return this.tilesToPixels(Math.min(maxTiles, n)) + padding;
|
return this.tilesToPixels(Math.min(maxTiles, n)) + padding;
|
||||||
}
|
}
|
||||||
|
|
||||||
public tilesToPixelsWithPadding(n: number, padding: number): number {
|
public tilesWithPadding(n: number, paddingPx: number): number {
|
||||||
return this.tilesToPixels(n) + padding;
|
return this.pixelsToTiles(this.tilesToPixelsWithPadding(n, paddingPx));
|
||||||
|
}
|
||||||
|
|
||||||
|
public tilesToPixelsWithPadding(n: number, paddingPx: number): number {
|
||||||
|
return this.tilesToPixels(n) + paddingPx;
|
||||||
}
|
}
|
||||||
|
|
||||||
public tilesToPixels(n: number): number {
|
public tilesToPixels(n: number): number {
|
||||||
|
|
Loading…
Reference in New Issue