Skip to content

Commit 470af0a

Browse files
committed
Added defaultSelectedTab webpart property
1 parent b8c424c commit 470af0a

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

src/controls/filePicker/FilePicker.tsx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -455,7 +455,7 @@ export class FilePicker extends React.Component<
455455
props: IFilePickerProps,
456456
orgAssetsEnabled: boolean
457457
): string => {
458-
const tabConfig = [
458+
const tabsConfig = [
459459
{ isTabVisible: !props.hideRecentTab, tabKey: "keyRecent" },
460460
{ isTabVisible: !props.hideStockImages, tabKey: "keyStockImages" },
461461
{ isTabVisible: props.bingAPIKey && !props.hideWebSearchTab, tabKey: "keyWeb" },
@@ -467,9 +467,15 @@ export class FilePicker extends React.Component<
467467
{ isTabVisible: !props.hideLocalMultipleUploadTab, tabKey: "keyMultipleUpload" }
468468
];
469469

470-
const visibleTabs = tabConfig.filter(tab => tab.isTabVisible);
470+
const visibleTabs = tabsConfig.filter(tab => tab.isTabVisible);
471471
const visibleTabKeys = visibleTabs.map(tab => tab.tabKey);
472472

473+
// If defaultSelectedTab is provided and is visible, then return tabKey
474+
if(this.props.defaultSelectedTab ?? visibleTabKeys.includes(this.props.defaultSelectedTab)) {
475+
return this.props.defaultSelectedTab;
476+
}
477+
478+
// If no valid default tab is provided, find the first visible tab in the order
473479
if (this.props.tabOrder) {
474480
const visibleTabSet = new Set(visibleTabKeys);
475481
return this.tabOrder.find(key => visibleTabSet.has(key));

src/controls/filePicker/IFilePickerProps.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,4 +180,10 @@ export interface IFilePickerProps {
180180
* default ["keyRecent", "keyStockImages", "keyWeb", "keyOrgAssets", "keyOneDrive", "keySite", "keyUpload", "keyLink", "keyMultipleUpload"]
181181
*/
182182
tabOrder?: string[];
183+
/**
184+
* Specifies default selected tab
185+
* One of the keys from tabOrder
186+
* One of ["keyRecent", "keyStockImages", "keyWeb", "keyOrgAssets", "keyOneDrive", "keySite", "keyUpload", "keyLink", "keyMultipleUpload"]
187+
*/
188+
defaultSelectedTab?: string;
183189
}

0 commit comments

Comments
 (0)