Skip to content

Commit 33d9932

Browse files
Merge pull request #1559 from DMichev/dev
fix issue with initial rendering of the TilesList
2 parents 00b54a9 + d662f52 commit 33d9932

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

src/controls/filePicker/controls/TilesList/TilesList.tsx

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,17 @@ export class TilesList extends React.Component<ITilesListProps> {
5353
}
5454

5555
public componentDidUpdate(prevProps: ITilesListProps): void {
56-
if (this.props.filePickerResults !== prevProps.filePickerResults) {
56+
if ((this.props.filePickerResults !== prevProps.filePickerResults) || (this._pageWidth === -1)) {
5757
this._listElem.forceUpdate();
5858
}
5959
}
6060

61+
public componentDidMount(): void {
62+
if (this._pageWidth === -1) {
63+
this.forceUpdate();
64+
}
65+
}
66+
6167
public render(): React.ReactElement<ITilesListProps> {
6268
return (
6369
<SelectionZone selection={this.props.selection} onItemInvoked={(item: IFile) => { this._handleItemInvoked(item); }}>
@@ -96,10 +102,9 @@ export class TilesList extends React.Component<ITilesListProps> {
96102
private _getItemCountForPage = (itemIndex: number, surfaceRect: IRectangle): number => {
97103
if (itemIndex === 0) {
98104
if (surfaceRect.width === 0) {
99-
//surfaceRect.width is 0 on load of this component, passing some default values so it renders.
100-
this._columnCount = 5;
101-
this._columnWidth = 232;
102-
this._pageWidth = 232;
105+
//surfaceRect.width is 0 on load of this component, so it won't render properly.
106+
//setting _pageWidth to -1 will re-render the entire component so surfaceRect.width will be returned correctly
107+
this._pageWidth = -1;
103108
} else {
104109
this._columnCount = Math.ceil(surfaceRect.width / MAX_ROW_HEIGHT);
105110
this._columnWidth = Math.floor(surfaceRect.width / this._columnCount);

0 commit comments

Comments
 (0)