Skip to content

Commit 1998f85

Browse files
Allow panel on FilePicker to be open after first load
1 parent 53db2ea commit 1998f85

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

src/controls/filePicker/FilePicker.tsx

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ import WebSearchTab from "./WebSearchTab/WebSearchTab";
6565
export class FilePicker extends React.Component<
6666
IFilePickerProps,
6767
IFilePickerState
68-
> {
68+
> {
6969
private fileBrowserService: FileBrowserService;
7070
private oneDriveService: OneDriveService;
7171
private orgAssetsService: OrgAssetsService;
@@ -115,6 +115,20 @@ export class FilePicker extends React.Component<
115115
});
116116
}
117117

118+
/**
119+
* componentWillReceiveProps lifecycle hook
120+
*
121+
* @param nextProps
122+
*/
123+
public componentWillReceiveProps(nextProps: IFilePickerProps): void {
124+
if (nextProps.isPanelOpen || nextProps.isPanelOpen !== this.props.isPanelOpen) {
125+
this.setState({
126+
panelOpen: nextProps.isPanelOpen
127+
});
128+
129+
}
130+
}
131+
118132
public render(): JSX.Element {
119133
// If no acceptable file type was passed, and we're expecting images, set the default image filter
120134
const accepts: string[] = this.props.accepts;
@@ -161,8 +175,8 @@ export class FilePicker extends React.Component<
161175
{this.props.buttonIcon || this.props.buttonIconProps ? (
162176
<ActionButton iconProps={buttonIconProps} {...buttonProps} />
163177
) : (
164-
<PrimaryButton {...buttonProps} />
165-
)}
178+
<PrimaryButton {...buttonProps} />
179+
)}
166180

167181
<Panel
168182
isOpen={this.state.panelOpen}

0 commit comments

Comments
 (0)