File tree Expand file tree Collapse file tree 1 file changed +10
-5
lines changed
src/controls/filePicker/controls/TilesList Expand file tree Collapse file tree 1 file changed +10
-5
lines changed Original file line number Diff line number Diff line change @@ -53,11 +53,17 @@ export class TilesList extends React.Component<ITilesListProps> {
53
53
}
54
54
55
55
public componentDidUpdate ( prevProps : ITilesListProps ) : void {
56
- if ( this . props . filePickerResults !== prevProps . filePickerResults ) {
56
+ if ( ( this . props . filePickerResults !== prevProps . filePickerResults ) || ( this . _pageWidth === - 1 ) ) {
57
57
this . _listElem . forceUpdate ( ) ;
58
58
}
59
59
}
60
60
61
+ public componentDidMount ( ) : void {
62
+ if ( this . _pageWidth === - 1 ) {
63
+ this . forceUpdate ( ) ;
64
+ }
65
+ }
66
+
61
67
public render ( ) : React . ReactElement < ITilesListProps > {
62
68
return (
63
69
< SelectionZone selection = { this . props . selection } onItemInvoked = { ( item : IFile ) => { this . _handleItemInvoked ( item ) ; } } >
@@ -96,10 +102,9 @@ export class TilesList extends React.Component<ITilesListProps> {
96
102
private _getItemCountForPage = ( itemIndex : number , surfaceRect : IRectangle ) : number => {
97
103
if ( itemIndex === 0 ) {
98
104
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 ;
103
108
} else {
104
109
this . _columnCount = Math . ceil ( surfaceRect . width / MAX_ROW_HEIGHT ) ;
105
110
this . _columnWidth = Math . floor ( surfaceRect . width / this . _columnCount ) ;
You can’t perform that action at this time.
0 commit comments