Skip to content

Commit 0702e96

Browse files
authored
Merge pull request #696 from aaclage/Feature/FixStickyHeaderStyles
Fix ListView > stickyHeaderStyles with a Classname.
2 parents 87fe8af + ad402bd commit 0702e96

File tree

2 files changed

+15
-54
lines changed

2 files changed

+15
-54
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
.StickyHeader .ms-DetailsList-contentWrapper {
2+
max-height: 40vh;
3+
overflow-y: auto;
4+
overflow-x: hidden;
5+
}

src/controls/listView/ListView.tsx

Lines changed: 10 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -3,49 +3,18 @@ import styles from './ListView.DragDrop.module.scss';
33
import { DetailsList, DetailsListLayoutMode, Selection, SelectionMode, IGroup, IDetailsHeaderProps } from 'office-ui-fabric-react/lib/DetailsList';
44
import { IListViewProps, IListViewState, IViewField, IGrouping, GroupOrder } from './IListView';
55
import { IColumn, IGroupRenderProps, IObjectWithKey } from 'office-ui-fabric-react/lib/components/DetailsList';
6-
import { ScrollablePane, ScrollbarVisibility } from 'office-ui-fabric-react/lib/ScrollablePane';
7-
import { Sticky, StickyPositionType } from 'office-ui-fabric-react/lib/Sticky';
8-
import { IRenderFunction } from 'office-ui-fabric-react/lib/Utilities';
96
import { findIndex, has, sortBy, isEqual, cloneDeep } from '@microsoft/sp-lodash-subset';
107
import { FileTypeIcon, IconType } from '../fileTypeIcon/index';
118
import * as strings from 'ControlStrings';
129
import { IGroupsItems } from './IListView';
1310
import * as telemetry from '../../common/telemetry';
1411
import { Icon } from 'office-ui-fabric-react/lib/Icon';
15-
import { mergeStyleSets } from 'office-ui-fabric-react/lib/Styling';
12+
import './ListView.stickyHeader.css';
1613

1714
import filter from 'lodash/filter';
1815
import { SearchBox } from 'office-ui-fabric-react/lib/SearchBox';
1916
import { Guid } from '@microsoft/sp-core-library';
2017

21-
const classNames = mergeStyleSets({
22-
wrapper: {
23-
height: '50vh',
24-
position: 'relative'
25-
}
26-
});
27-
28-
/**
29-
* Wrap the listview in a scrollable pane if sticky header = true
30-
*/
31-
const ListViewWrapper = ({ stickyHeader, children }) => (stickyHeader ?
32-
<div className={classNames.wrapper} >
33-
<ScrollablePane scrollbarVisibility={ScrollbarVisibility.auto}>
34-
{children}
35-
</ScrollablePane>
36-
</div>
37-
: children
38-
);
39-
40-
/**
41-
* Lock the searchbox when scrolling if sticky header = true
42-
*/
43-
const SearchBoxWrapper = ({ stickyHeader, children }) => (stickyHeader ?
44-
<Sticky stickyPosition={StickyPositionType.Header}>
45-
{children}
46-
</Sticky>
47-
: children
48-
);
4918

5019
/**
5120
* File type icon component
@@ -596,22 +565,15 @@ export class ListView extends React.Component<IListViewProps, IListViewState> {
596565
}
597566
}
598567

599-
/**
600-
* Custom render of header
601-
* @param props
602-
* @param defaultRender
603-
*/
604-
private _onRenderDetailsHeader: IRenderFunction<IDetailsHeaderProps> = (props, defaultRender) => {
605-
if (!props) {
606-
return null;
568+
/**
569+
* Return Classname with StickyHeader
570+
*/
571+
private _getClassName() {
572+
if (this.props.stickyHeader) {
573+
return "StickyHeader";
574+
} else {
575+
return "";
607576
}
608-
return (
609-
<Sticky stickyPosition={StickyPositionType.Header} isScrollSynced>
610-
{defaultRender!({
611-
...props,
612-
})}
613-
</Sticky>
614-
);
615577
}
616578

617579
/**
@@ -645,13 +607,9 @@ export class ListView extends React.Component<IListViewProps, IListViewState> {
645607
</div>
646608
</div>
647609
}
648-
<ListViewWrapper stickyHeader={!!stickyHeader}>
649-
<div>
650610
{
651611
showFilter &&
652-
<SearchBoxWrapper stickyHeader={!!stickyHeader}>
653612
<SearchBox placeholder={filterPlaceHolder || strings.ListViewFilterLabel} onSearch={this._updateFilterValue} onChange={this._updateFilterValue} value={filterValue} />
654-
</SearchBoxWrapper>
655613
}
656614
<DetailsList
657615
key="ListViewControl"
@@ -665,10 +623,8 @@ export class ListView extends React.Component<IListViewProps, IListViewState> {
665623
compact={compact}
666624
setKey="ListViewControl"
667625
groupProps={groupProps}
668-
onRenderDetailsHeader={this._onRenderDetailsHeader}
626+
className={this._getClassName()}
669627
/>
670-
</div>
671-
</ListViewWrapper>
672628
</div>
673629
);
674630
}

0 commit comments

Comments
 (0)