From a0f9d344a8da9bce313ad4c29d5af8c748763337 Mon Sep 17 00:00:00 2001 From: mertsincan Date: Wed, 31 Aug 2022 11:07:32 +0100 Subject: [PATCH] Fixed #2846 - Add resetFilterOnHide property to Dropdown --- api-generator/components/dropdown.js | 6 ++++++ src/components/dropdown/Dropdown.d.ts | 4 ++++ src/components/dropdown/Dropdown.vue | 5 +++++ src/views/dropdown/DropdownDoc.vue | 6 ++++++ 4 files changed, 21 insertions(+) diff --git a/api-generator/components/dropdown.js b/api-generator/components/dropdown.js index 8f132fcf2..31e0ad4f8 100644 --- a/api-generator/components/dropdown.js +++ b/api-generator/components/dropdown.js @@ -179,6 +179,12 @@ const DropdownProps = [ default: "pi pi-spinner pi-spin", description: "Icon to display in loading state." }, + { + name: "resetFilterOnHide", + type: "boolean", + default: "false", + description: "Clears the filter value when hiding the dropdown." + }, { name: "virtualScrollerOptions", type: "object", diff --git a/src/components/dropdown/Dropdown.d.ts b/src/components/dropdown/Dropdown.d.ts index fb34f5bf3..fdf82e0ef 100755 --- a/src/components/dropdown/Dropdown.d.ts +++ b/src/components/dropdown/Dropdown.d.ts @@ -168,6 +168,10 @@ export interface DropdownProps { * Default value is 'pi pi-spinner pi-spin'. */ 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. * @see VirtualScroller.VirtualScrollerProps diff --git a/src/components/dropdown/Dropdown.vue b/src/components/dropdown/Dropdown.vue index 863b00f02..bb34971f8 100755 --- a/src/components/dropdown/Dropdown.vue +++ b/src/components/dropdown/Dropdown.vue @@ -132,6 +132,10 @@ export default { type: String, default: 'pi pi-spinner pi-spin' }, + resetFilterOnHide: { + type: Boolean, + default: false + }, virtualScrollerOptions: { type: Object, default: null @@ -272,6 +276,7 @@ export default { this.focusedOptionIndex = -1; this.searchValue = ''; + this.resetFilterOnHide && (this.filterValue = null); isFocus && this.$refs.focusInput && this.$refs.focusInput.focus(); } diff --git a/src/views/dropdown/DropdownDoc.vue b/src/views/dropdown/DropdownDoc.vue index c03ec8bc6..843b6dd7f 100755 --- a/src/views/dropdown/DropdownDoc.vue +++ b/src/views/dropdown/DropdownDoc.vue @@ -312,6 +312,12 @@ export default { pi pi-spinner pi-spin Icon to display in loading state. + + resetFilterOnHide + boolean + false + Clears the filter value when hiding the dropdown. + virtualScrollerOptions object