Skip to content

Commit 3a971df

Browse files
Allow FilePicker button to be hidden
1 parent bca3dd0 commit 3a971df

File tree

3 files changed

+15
-6
lines changed

3 files changed

+15
-6
lines changed

docs/documentation/docs/controls/FilePicker.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,11 +62,13 @@ The FilePicker component can be configured with the following properties:
6262
buttonIconProps | IIconProps | no | In case it is provided the file picker will be rendered as an Icon the and all can define Properties for Icon |
6363
| onSave | (filePickerResult: IFilePickerResult) => void | yes | Handler when the file has been selected and picker has been closed. |
6464
| onChange | (filePickerResult: IFilePickerResult) => void | no | Handler when the file selection has been changed. |
65+
| onCancel | () => void | no | Handler when file picker has been cancelled. |
6566
| context | BaseComponentContext | yes | Current context. |
6667
| accepts | string[] | no | Array of strings containing allowed files extensions. E.g. [".gif", ".jpg", ".jpeg", ".bmp", ".dib", ".tif", ".tiff", ".ico", ".png", ".jxr", ".svg"] |
6768
| required | boolean | no | Sets the label to inform that the value is required. |
6869
| bingAPIKey | string | no | Used to execute WebSearch. If not provided SearchTab will not be available. |
6970
| disabled | boolean | no | Specifies if the picker button is disabled |
71+
| hidden | boolean | no | Specifies if the picker button is hidden (if hidden, panel visibility can still be controlled with isPanelOpen) |
7072
| itemsCountQueryLimit | number | no | Number of items to obtain when executing REST queries. Default 100. |
7173
| hideRecentTab | boolean | no | Specifies if RecentTab should be hidden. |
7274
| hideWebSearchTab | boolean | no | Specifies if WebSearchTab should be hidden. |
@@ -77,6 +79,7 @@ The FilePicker component can be configured with the following properties:
7779
| hideLocalUploadTab | boolean | no | Specifies if LocalUploadTab should be hidden. |
7880
| hideLinkUploadTab | boolean | no | Specifies if LinkUploadTab should be hidden. |
7981
| storeLastActiveTab | boolean | no | Specifies if last active tab will be stored after the Upload panel has been closed. Note: the value of selected tab is stored in the queryString hash. Default `true` |
82+
| isPanelOpen | boolean | no | Specifies if the file picker panel is open by default or not |
8083
| renderCustomUploadTabContent | (filePickerResult: IFilePickerResult) => JSX.Element \| null | no | Optional renderer to add custom user-defined fields to "Upload" tab |
8184
| renderCustomLinkTabContent | (filePickerResult: IFilePickerResult) => JSX.Element \| null | no | Optional renderer to add custom user-defined fields to "Link" tab |
8285
| includePageLibraries | boolean | no | Specifies if Site Pages library to be visible on Sites tab |

src/controls/filePicker/FilePicker.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -169,12 +169,13 @@ export class FilePicker extends React.Component<
169169

170170
return (
171171
<div className={`pnp__file-picker`}>
172-
{this.props.label && (
172+
{!this.props.hidden && this.props.label && (
173173
<Label required={this.props.required}>{this.props.label}</Label>
174174
)}
175-
{this.props.buttonIcon || this.props.buttonIconProps ? (
175+
{!this.props.hidden && (this.props.buttonIcon || this.props.buttonIconProps) ? (
176176
<ActionButton iconProps={buttonIconProps} {...buttonProps} />
177177
) : (
178+
!this.props.hidden &&
178179
<PrimaryButton {...buttonProps} />
179180
)}
180181

src/controls/filePicker/IFilePickerProps.ts

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,16 @@ export interface IFilePickerProps {
1818
* Specifies the icon to be used to display Icon Button.
1919
*/
2020
buttonIcon?: string;
21-
/**
22-
* Specifies props for icon to be used to display Icon Button.
23-
*/
21+
/**
22+
* Specifies props for icon to be used to display Icon Button.
23+
*/
2424
buttonIconProps?: IIconProps;
2525

2626

2727
/**
2828
* Handler when the file has been selected
2929
*/
30-
onSave:(filePickerResult: IFilePickerResult)=>void;
30+
onSave: (filePickerResult: IFilePickerResult) => void;
3131

3232
/**
3333
* Handler when file has been changed.
@@ -69,6 +69,11 @@ export interface IFilePickerProps {
6969
*/
7070
disabled?: boolean;
7171

72+
/**
73+
* Specifies if the picker button is hidden (if hidden, panel visibility can still be controlled with isPanelOpen)
74+
*/
75+
hidden?: boolean;
76+
7277
/**
7378
* Number of itmes to obtain when executing REST queries. Default 100.
7479
*/

0 commit comments

Comments
 (0)