Skip to content

Commit

Permalink
Merge branch 'PlaceHolderRender' of https://github.com/jason-appliedi…
Browse files Browse the repository at this point in the history
…s/sp-dev-fx-controls-react into jason-appliedis-PlaceHolderRender
  • Loading branch information
AJIXuMuK committed Feb 19, 2020
2 parents 565793f + 4035e90 commit be3422f
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 2 deletions.
4 changes: 4 additions & 0 deletions src/controls/listView/IListView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ export interface IListViewProps {
* Specify the placeholder for the filter text box. Default 'Search'
*/
filterPlaceHolder?: string;
/**
* Specify if the filter width in % 0 - 100.
*/
filterWidth?: number;
/**
* Specify if the filter text box should be rendered.
*/
Expand Down
8 changes: 6 additions & 2 deletions src/controls/listView/ListView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -500,7 +500,7 @@ export class ListView extends React.Component<IListViewProps, IListViewState> {
public render(): React.ReactElement<IListViewProps> {
let groupProps: IGroupRenderProps = {};

let { showFilter, filterPlaceHolder } = this.props;
let { showFilter, filterPlaceHolder, filterWidth } = this.props;
let { filterValue, items } = this.state;

// Check if selection mode is single selection,
Expand All @@ -517,7 +517,11 @@ export class ListView extends React.Component<IListViewProps, IListViewState> {
return (
<div>
{
showFilter && <TextField placeholder={filterPlaceHolder || strings.ListViewFilterLabel} onChanged={this._updateFilterValue} value={filterValue}/>
showFilter &&
// Add div to control the width of the filter for the list view dynamically allowing users to enter a number 0-100 % to alter the field width
<div style={{width:`${filterWidth}%`}}>
<TextField placeholder={filterPlaceHolder || strings.ListViewFilterLabel} onChanged={this._updateFilterValue} value={filterValue}/>
</div>
}
<DetailsList
key="ListViewControl"
Expand Down
11 changes: 11 additions & 0 deletions src/controls/placeholder/PlaceholderComponent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,17 @@ export class Placeholder extends React.Component<IPlaceholderProps, IPlaceholder
* @param nextState
*/
public shouldComponentUpdate(nextProps: IPlaceholderProps, nextState: IPlaceholderState): boolean {
/*
* compare the props object for changes in primative values
* Return/re-render, bexeting the function, if the props change
*/
for (const property in nextProps) {
if (property != '_onConfigure'){
if (nextProps[property] != this.props[property]) {
return true;
}
}
}
return this.state.width !== nextState.width || this.props.hideButton !== nextProps.hideButton;
}

Expand Down

0 comments on commit be3422f

Please sign in to comment.