Skip to content

Commit be3422f

Browse files
committed
Merge branch 'PlaceHolderRender' of https://github.com/jason-appliedis/sp-dev-fx-controls-react into jason-appliedis-PlaceHolderRender
2 parents 565793f + 4035e90 commit be3422f

File tree

3 files changed

+21
-2
lines changed

3 files changed

+21
-2
lines changed

src/controls/listView/IListView.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,10 @@ export interface IListViewProps {
4747
* Specify the placeholder for the filter text box. Default 'Search'
4848
*/
4949
filterPlaceHolder?: string;
50+
/**
51+
* Specify if the filter width in % 0 - 100.
52+
*/
53+
filterWidth?: number;
5054
/**
5155
* Specify if the filter text box should be rendered.
5256
*/

src/controls/listView/ListView.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -500,7 +500,7 @@ export class ListView extends React.Component<IListViewProps, IListViewState> {
500500
public render(): React.ReactElement<IListViewProps> {
501501
let groupProps: IGroupRenderProps = {};
502502

503-
let { showFilter, filterPlaceHolder } = this.props;
503+
let { showFilter, filterPlaceHolder, filterWidth } = this.props;
504504
let { filterValue, items } = this.state;
505505

506506
// Check if selection mode is single selection,
@@ -517,7 +517,11 @@ export class ListView extends React.Component<IListViewProps, IListViewState> {
517517
return (
518518
<div>
519519
{
520-
showFilter && <TextField placeholder={filterPlaceHolder || strings.ListViewFilterLabel} onChanged={this._updateFilterValue} value={filterValue}/>
520+
showFilter &&
521+
// 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
522+
<div style={{width:`${filterWidth}%`}}>
523+
<TextField placeholder={filterPlaceHolder || strings.ListViewFilterLabel} onChanged={this._updateFilterValue} value={filterValue}/>
524+
</div>
521525
}
522526
<DetailsList
523527
key="ListViewControl"

src/controls/placeholder/PlaceholderComponent.tsx

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,17 @@ export class Placeholder extends React.Component<IPlaceholderProps, IPlaceholder
5454
* @param nextState
5555
*/
5656
public shouldComponentUpdate(nextProps: IPlaceholderProps, nextState: IPlaceholderState): boolean {
57+
/*
58+
* compare the props object for changes in primative values
59+
* Return/re-render, bexeting the function, if the props change
60+
*/
61+
for (const property in nextProps) {
62+
if (property != '_onConfigure'){
63+
if (nextProps[property] != this.props[property]) {
64+
return true;
65+
}
66+
}
67+
}
5768
return this.state.width !== nextState.width || this.props.hideButton !== nextProps.hideButton;
5869
}
5970

0 commit comments

Comments
 (0)