Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: file picker recent tab wont render until page re-sized, adds def… #1483

Merged
merged 1 commit into from
Mar 5, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 13 additions & 9 deletions src/controls/filePicker/RecentFilesTab/RecentFilesTab.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,10 @@ export default class RecentFilesTab extends React.Component<IRecentFilesTabProps

this._selection = null;


this.state = {
isLoading: true,
results: [],
filePickerResults: []
filePickerResults: [],
};
}

Expand Down Expand Up @@ -123,11 +122,16 @@ export default class RecentFilesTab extends React.Component<IRecentFilesTabProps
*/
private _getItemCountForPage = (itemIndex: number, surfaceRect: IRectangle): number => {
if (itemIndex === 0) {
this._columnCount = Math.ceil(surfaceRect.width / MAX_ROW_HEIGHT);
this._columnWidth = Math.floor(surfaceRect.width / this._columnCount);
this._rowHeight = this._columnWidth;
if (surfaceRect.width === 0) {
//surfaceRect.width is 0 on load of this component, passing some default values so it renders.
this._columnCount = 9;
this._columnWidth = 161;
} else {
this._columnCount = Math.ceil(surfaceRect.width / MAX_ROW_HEIGHT);
this._columnWidth = Math.floor(surfaceRect.width / this._columnCount);
}
this._rowHeight = this._columnWidth;
}

return this._columnCount * ROWS_PER_PAGE;
}

Expand Down Expand Up @@ -157,7 +161,7 @@ export default class RecentFilesTab extends React.Component<IRecentFilesTabProps
/**
* Renders a grid list containing results
*/
private _renderGridList = (): JSX.Element => {
private _renderGridList = (): JSX.Element => {
return <span className={styles.recentGridList} role="grid">
<FocusZone>
<SelectionZone selection={this._selection}
Expand All @@ -168,9 +172,9 @@ export default class RecentFilesTab extends React.Component<IRecentFilesTabProps
<List
ref={this._linkElement}
items={this.state.results}
onRenderCell={this._onRenderCell}
onRenderCell={this._onRenderCell}
getItemCountForPage={this._getItemCountForPage}
getPageHeight={this._getPageHeight}
getPageHeight={this._getPageHeight}
renderedWindowsAhead={4}
/>
</SelectionZone>
Expand Down