Skip to content

Commit

Permalink
Fixed #1215, Fixed #1242
Browse files Browse the repository at this point in the history
  • Loading branch information
cagataycivici committed Mar 10, 2020
1 parent cbda8f3 commit 129a7b7
Show file tree
Hide file tree
Showing 8 changed files with 33 additions and 11 deletions.
1 change: 1 addition & 0 deletions src/components/listbox/ListBox.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ interface ListBoxProps {
multiple?: boolean;
metaKeySelection?: boolean;
filter?: boolean;
filterPlaceholder?: string;
tabIndex?:string;
tooltip?: any;
tooltipOptions?: TooltipOptions;
Expand Down
4 changes: 3 additions & 1 deletion src/components/listbox/ListBox.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export class ListBox extends Component {
multiple: false,
metaKeySelection: false,
filter: false,
filterPlaceholder: null,
tabIndex: '0',
tooltip: null,
tooltipOptions: null,
Expand All @@ -44,6 +45,7 @@ export class ListBox extends Component {
multiple: PropTypes.bool,
metaKeySelection: PropTypes.bool,
filter: PropTypes.bool,
filterPlaceholder: PropTypes.string,
tabIndex: PropTypes.string,
tooltip: PropTypes.string,
tooltipOptions: PropTypes.object,
Expand Down Expand Up @@ -278,7 +280,7 @@ export class ListBox extends Component {
}

if(this.props.filter) {
header = <ListBoxHeader filter={this.state.filter} onFilter={this.onFilter} disabled={this.props.disabled} />
header = <ListBoxHeader filter={this.state.filter} onFilter={this.onFilter} disabled={this.props.disabled} filterPlaceholder={this.props.filterPlaceholder} />
}

return (
Expand Down
4 changes: 3 additions & 1 deletion src/components/listbox/ListBoxHeader.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,14 @@ export class ListBoxHeader extends Component {

static defaultProps = {
filter: null,
filterPlaceholder: null,
disabled: false,
onFilter: null
}

static propTypes = {
filter: PropTypes.string,
filterPlaceholder: PropTypes.string,
disabled: PropTypes.bool,
onFilter: PropTypes.func
}
Expand All @@ -34,7 +36,7 @@ export class ListBoxHeader extends Component {
return (
<div className="p-listbox-header">
<div className="p-listbox-filter-container">
<InputText type="text" value={this.props.filter} onChange={this.onFilter} disabled={this.props.disabled} />
<InputText type="text" value={this.props.filter} onChange={this.onFilter} disabled={this.props.disabled} placeholder={this.props.filterPlaceholder} />
<span className="p-listbox-filter-icon pi pi-search"></span>
</div>
</div>
Expand Down
1 change: 1 addition & 0 deletions src/components/multiselect/MultiSelect.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ interface MultiSelectProps {
fixedPlaceholder?: boolean;
disabled?: boolean;
filter?: boolean;
filterPlaceholder?: string;
tabIndex?: boolean;
dataKey?: string;
appendTo?: HTMLElement;
Expand Down
4 changes: 3 additions & 1 deletion src/components/multiselect/MultiSelect.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export class MultiSelect extends Component {
fixedPlaceholder: false,
disabled: false,
filter: false,
filterPlaceholder: null,
tabIndex: '0',
dataKey: null,
appendTo: null,
Expand Down Expand Up @@ -51,6 +52,7 @@ export class MultiSelect extends Component {
fixedPlaceholder: PropTypes.bool,
disabled: PropTypes.bool,
filter: PropTypes.bool,
filterPlaceholder: PropTypes.string,
tabIndex: PropTypes.string,
dataKey: PropTypes.string,
appendTo: PropTypes.object,
Expand Down Expand Up @@ -458,7 +460,7 @@ export class MultiSelect extends Component {

renderHeader(items) {
return (
<MultiSelectHeader filter={this.props.filter} filterValue={this.state.filter} onFilter={this.onFilter}
<MultiSelectHeader filter={this.props.filter} filterValue={this.state.filter} onFilter={this.onFilter} filterPlaceholder={this.props.filterPlaceholder}
onClose={this.onCloseClick} onToggleAll={this.onToggleAll} allChecked={this.isAllChecked(items)} />
);
}
Expand Down
4 changes: 3 additions & 1 deletion src/components/multiselect/MultiSelectHeader.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export class MultiSelectHeader extends Component {
static defaultProps = {
filter: false,
filterValue: null,
filterPlaceholder: null,
onFilter: null,
onClose: null,
onToggleAll: null,
Expand All @@ -17,6 +18,7 @@ export class MultiSelectHeader extends Component {
static propTypes = {
filter: PropTypes.bool,
filterValue: PropTypes.string,
filterPlaceholder: PropTypes.string,
allChecked: PropTypes.bool,
onFilter: PropTypes.func,
onClose: PropTypes.func,
Expand Down Expand Up @@ -52,7 +54,7 @@ export class MultiSelectHeader extends Component {
return (
<div className="p-multiselect-filter-container">
<InputText type="text" role="textbox" value={this.props.filterValue} onChange={this.onFilter}
className="p-inputtext p-component" />
className="p-inputtext p-component" placeholder={this.props.filterPlaceholder}/>
<span className="p-multiselect-filter-icon pi pi-search"></span>
</div>
);
Expand Down
12 changes: 9 additions & 3 deletions src/showcase/listbox/ListBoxDemo.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ export class ListBoxDemo extends Component {
<ListBox value={this.state.cities} options={cities} onChange={(e) => this.setState({cities: e.value})} multiple={true} optionLabel="name"/>

<h3>Advanced</h3>
<ListBox value={this.state.car} filter={true} options={cars} onChange={(e) => this.setState({car: e.value})} itemTemplate={this.carTemplate}
style={{width: '15em'}} listStyle={{maxHeight: '250px'}}/>
<ListBox value={this.state.car} filter={true} filterPlaceholder="Search" options={cars} onChange={(e) => this.setState({car: e.value})} itemTemplate={this.carTemplate}
style={{width: '15em'}} listStyle={{maxHeight: '250px'}} />
</div>

<ListboxDoc></ListboxDoc>
Expand Down Expand Up @@ -341,6 +341,12 @@ carTemplate(option) {
<td>false</td>
<td>When specified, displays a filter input at header.</td>
</tr>
<tr>
<td>filterPlaceholder</td>
<td>string</td>
<td>null</td>
<td>Placeholder text to show when filter input is empty.</td>
</tr>
<tr>
<td>tabIndex</td>
<td>string</td>
Expand Down Expand Up @@ -493,7 +499,7 @@ export class ListBoxDemo extends Component {
<ListBox value={this.state.cities} options={cities} onChange={(e) => this.setState({cities: e.value})} multiple={true} optionLabel="name"/>
<h3>Advanced</h3>
<ListBox value={this.state.car} filter={true} options={cars} onChange={(e) => this.setState({car: e.value})} itemTemplate={this.carTemplate}
<ListBox value={this.state.car} filter={true} filterPlaceholder="Search" options={cars} onChange={(e) => this.setState({car: e.value})} itemTemplate={this.carTemplate}
style={{width: '15em'}} listStyle={{maxHeight: '250px'}}/>
</div>
</div>
Expand Down
14 changes: 10 additions & 4 deletions src/showcase/multiselect/MultiSelectDemo.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,11 @@ export class MultiSelectDemo extends Component {
<div className="content-section implementation multiselect-demo">
<h3>Basic</h3>
<MultiSelect value={this.state.cars1} options={cars} onChange={(e) => this.setState({cars1: e.value})}
style={{minWidth:'12em'}} filter={true} placeholder="Choose" />
style={{minWidth:'15em'}} filter={true} filterPlaceholder="Search" placeholder="Choose" />

<h3>Templating</h3>
<MultiSelect value={this.state.cars2} options={cars} onChange={(e) => this.setState({cars2: e.value})}
style={{minWidth:'12em'}} filter={true} itemTemplate={this.carTemplate} selectedItemTemplate={this.selectedCarTemplate} />
style={{minWidth:'15em'}} filter={true} filterPlaceholder="Search" itemTemplate={this.carTemplate} selectedItemTemplate={this.selectedCarTemplate} />
</div>

<MultiSelectDoc />
Expand Down Expand Up @@ -345,6 +345,12 @@ selectedCarTemplate(option) {
<td>true</td>
<td>When specified, displays an input field to filter the items on keyup.</td>
</tr>
<tr>
<td>filterPlaceholder</td>
<td>string</td>
<td>null</td>
<td>Placeholder text to show when filter input is empty.</td>
</tr>
<tr>
<td>tabIndex</td>
<td>string</td>
Expand Down Expand Up @@ -566,11 +572,11 @@ export class MultiSelectDemo extends Component {
<div className="content-section implementation multiselect-demo">
<h3>Basic</h3>
<MultiSelect value={this.state.cars1} options={cars} onChange={(e) => this.setState({cars1: e.value})}
style={{minWidth:'12em'}} filter={true} placeholder="Choose" />
style={{minWidth:'12em'}} filter={true} filterPlaceholder="Search" placeholder="Choose" />
<h3>Templating</h3>
<MultiSelect value={this.state.cars2} options={cars} onChange={(e) => this.setState({cars2: e.value})}
style={{minWidth:'12em'}} filter={true} itemTemplate={this.carTemplate} selectedItemTemplate={this.selectedCarTemplate} />
style={{minWidth:'12em'}} filter={true} filterPlaceholder="Search" itemTemplate={this.carTemplate} selectedItemTemplate={this.selectedCarTemplate} />
</div>
</div>
);
Expand Down

0 comments on commit 129a7b7

Please sign in to comment.