Fixed #2846 - Add resetFilterOnHide property to Dropdown

pull/2929/head
mertsincan 2022-08-31 11:07:32 +01:00
parent 400cabe01f
commit a0f9d344a8
4 changed files with 21 additions and 0 deletions

View File

@ -179,6 +179,12 @@ const DropdownProps = [
default: "pi pi-spinner pi-spin", default: "pi pi-spinner pi-spin",
description: "Icon to display in loading state." description: "Icon to display in loading state."
}, },
{
name: "resetFilterOnHide",
type: "boolean",
default: "false",
description: "Clears the filter value when hiding the dropdown."
},
{ {
name: "virtualScrollerOptions", name: "virtualScrollerOptions",
type: "object", type: "object",

View File

@ -168,6 +168,10 @@ export interface DropdownProps {
* Default value is 'pi pi-spinner pi-spin'. * Default value is 'pi pi-spinner pi-spin'.
*/ */
loadingIcon?: string | undefined; loadingIcon?: string | undefined;
/**
* Clears the filter value when hiding the dropdown.
*/
resetFilterOnHide?: boolean;
/** /**
* Whether to use the virtualScroller feature. The properties of VirtualScroller component can be used like an object in it. * Whether to use the virtualScroller feature. The properties of VirtualScroller component can be used like an object in it.
* @see VirtualScroller.VirtualScrollerProps * @see VirtualScroller.VirtualScrollerProps

View File

@ -132,6 +132,10 @@ export default {
type: String, type: String,
default: 'pi pi-spinner pi-spin' default: 'pi pi-spinner pi-spin'
}, },
resetFilterOnHide: {
type: Boolean,
default: false
},
virtualScrollerOptions: { virtualScrollerOptions: {
type: Object, type: Object,
default: null default: null
@ -272,6 +276,7 @@ export default {
this.focusedOptionIndex = -1; this.focusedOptionIndex = -1;
this.searchValue = ''; this.searchValue = '';
this.resetFilterOnHide && (this.filterValue = null);
isFocus && this.$refs.focusInput && this.$refs.focusInput.focus(); isFocus && this.$refs.focusInput && this.$refs.focusInput.focus();
} }

View File

@ -312,6 +312,12 @@ export default {
<td>pi pi-spinner pi-spin</td> <td>pi pi-spinner pi-spin</td>
<td>Icon to display in loading state.</td> <td>Icon to display in loading state.</td>
</tr> </tr>
<tr>
<td>resetFilterOnHide</td>
<td>boolean</td>
<td>false</td>
<td>Clears the filter value when hiding the dropdown.</td>
</tr>
<tr> <tr>
<td>virtualScrollerOptions</td> <td>virtualScrollerOptions</td>
<td>object</td> <td>object</td>