Skip to content

Commit

Permalink
fix: disable open on click behavior
Browse files Browse the repository at this point in the history
Adds the disable-open-on-click attibute to the mgt-file-list to allow developers to prevent items with a webUrl from opening in a new browser window. The provides backwards function compatibility to v2
  • Loading branch information
gavinbarron committed Aug 25, 2023
1 parent cb69e01 commit 734ac4d
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -403,6 +403,11 @@ export class MgtFileList extends MgtTemplatedComponent implements CardSection {
void this.requestStateUpdate(true);
}

@property({
attribute: 'disable-open-on-click',
type: Boolean
})
public disableOpenOnClick = false;
/**
* A boolean value indication if 'show-more' button should be disabled
*
Expand Down Expand Up @@ -1007,7 +1012,7 @@ export class MgtFileList extends MgtTemplatedComponent implements CardSection {
}

private handleFileClick(file: DriveItem) {
if (file?.webUrl) {
if (file?.webUrl && !this.disableOpenOnClick) {
window.open(file.webUrl, '_blank', 'noreferrer');
}
}
Expand Down
2 changes: 1 addition & 1 deletion packages/mgt-element/src/utils/version.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@
// THIS FILE IS AUTO GENERATED
// ANY CHANGES WILL BE LOST DURING BUILD

export const PACKAGE_VERSION = '3.0.1';
export const PACKAGE_VERSION = '3.1.1';
1 change: 1 addition & 0 deletions packages/mgt-react/src/generated/react.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ export type FileListProps = {
itemView?: ViewType;
fileExtensions?: string[];
pageSize?: number;
disableOpenOnClick?: boolean;
hideMoreFilesButton?: boolean;
maxFileSize?: number;
enableFileUpload?: boolean;
Expand Down
4 changes: 4 additions & 0 deletions stories/components/fileList/fileList.properties.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,10 @@ export const getFileListByExtensions = () => html`
<mgt-file-list file-extensions="docx, xlsx"></mgt-file-list>
`;

export const disableOpenOnClick = () => html`
<mgt-file-list disable-open-on-click></mgt-file-list>
`;

export const disableFileExpansion = () => html`
<mgt-file-list hide-more-files-button></mgt-file-list>
`;
Expand Down

0 comments on commit 734ac4d

Please sign in to comment.