From 2f60b27fc4a27a3a6e044a943f046cd62004e9f1 Mon Sep 17 00:00:00 2001 From: aaclage Date: Sat, 12 Dec 2020 22:08:03 +0100 Subject: [PATCH] Revert Sticky Header to use ScrollablePane --- .../ListView.stickyHeader.module.scss | 10 -- src/controls/listView/ListView.tsx | 116 +++++++++++++----- 2 files changed, 83 insertions(+), 43 deletions(-) delete mode 100644 src/controls/listView/ListView.stickyHeader.module.scss diff --git a/src/controls/listView/ListView.stickyHeader.module.scss b/src/controls/listView/ListView.stickyHeader.module.scss deleted file mode 100644 index 61a94b9d6..000000000 --- a/src/controls/listView/ListView.stickyHeader.module.scss +++ /dev/null @@ -1,10 +0,0 @@ -.StickyHeader { - :global(.ms-FocusZone) { - max-height: 40vh; - overflow-y: overlay; - overflow-x: hidden; - } - :global(.ms-DetailsHeader) { - overflow-y: hidden; - } -} diff --git a/src/controls/listView/ListView.tsx b/src/controls/listView/ListView.tsx index 01ab73aae..46c05a7ad 100644 --- a/src/controls/listView/ListView.tsx +++ b/src/controls/listView/ListView.tsx @@ -1,7 +1,10 @@ import * as React from 'react'; import styles from './ListView.DragDrop.module.scss'; -import stickyHeaderstyles from './ListView.stickyHeader.module.scss'; -import { DetailsList, DetailsListLayoutMode, Selection, SelectionMode, IGroup } from 'office-ui-fabric-react/lib/DetailsList'; +import { ScrollablePane, ScrollbarVisibility } from 'office-ui-fabric-react/lib/ScrollablePane'; +import { Sticky, StickyPositionType } from 'office-ui-fabric-react/lib/Sticky'; +import { IRenderFunction } from 'office-ui-fabric-react/lib/Utilities'; +import { mergeStyleSets } from 'office-ui-fabric-react/lib/Styling'; +import { DetailsList, DetailsListLayoutMode, Selection, SelectionMode, IGroup, IDetailsHeaderProps } from 'office-ui-fabric-react/lib/DetailsList'; import { IListViewProps, IListViewState, IViewField, IGrouping, GroupOrder } from './IListView'; import { IColumn, IGroupRenderProps } from 'office-ui-fabric-react/lib/components/DetailsList'; import { findIndex, has, sortBy, isEqual, cloneDeep } from '@microsoft/sp-lodash-subset'; @@ -15,6 +18,35 @@ import filter from 'lodash/filter'; import { SearchBox } from 'office-ui-fabric-react/lib/SearchBox'; import { Guid } from '@microsoft/sp-core-library'; +const classNames = mergeStyleSets({ + wrapper: { + height: '50vh', + position: 'relative' + } +}); + +/** +* Wrap the listview in a scrollable pane if sticky header = true +*/ +const ListViewWrapper = ({ stickyHeader, children }) => (stickyHeader ? +
+ + {children} + +
+ : children +); + +/** +* Lock the searchbox when scrolling if sticky header = true +*/ +const SearchBoxWrapper = ({ stickyHeader, children }) => (stickyHeader ? + + {children} + + : children +); + /** * File type icon component @@ -564,6 +596,23 @@ export class ListView extends React.Component { this.dragCounter = 0; } } + /** + * Custom render of header + * @param props + * @param defaultRender + */ + private _onRenderDetailsHeader: IRenderFunction = (props, defaultRender) => { + if (!props) { + return null; + } + return ( + + {defaultRender!({ + ...props, + })} + + ); + } /** * Default React component render method */ @@ -585,38 +634,39 @@ export class ListView extends React.Component { } return ( -
- {(dragStatus && dragDropFiles) && -
-
- -
{strings.UploadFileHeader}
+ +
+ {(dragStatus && dragDropFiles) && +
+
+ +
{strings.UploadFileHeader}
+
-
- } - { - showFilter && - - } - -
+ } + { + showFilter && + + + + } + +
+ ); } }