From e1a6d4ea70d43a3fc0b548d56c0fb63edb80c05a Mon Sep 17 00:00:00 2001 From: Akshay Antony Date: Mon, 15 Jan 2024 15:39:51 +0530 Subject: [PATCH] fix: Primefaces#5060, Dropdown: After selecting an option, clearing the value using close icon should clear the filter input --- api-generator/components/dropdown.js | 6 ++++++ components/lib/dropdown/BaseDropdown.vue | 4 ++++ components/lib/dropdown/Dropdown.d.ts | 5 +++++ components/lib/dropdown/Dropdown.vue | 2 +- doc/common/apidoc/index.json | 8 ++++++++ 5 files changed, 24 insertions(+), 1 deletion(-) diff --git a/api-generator/components/dropdown.js b/api-generator/components/dropdown.js index 1a4f63222a..36b5e1a5fa 100644 --- a/api-generator/components/dropdown.js +++ b/api-generator/components/dropdown.js @@ -185,6 +185,12 @@ const DropdownProps = [ default: 'false', description: 'Clears the filter value when hiding the dropdown.' }, + { + name: 'resetFilterOnClear', + type: 'boolean', + default: 'false', + description: 'Clears the filter value when clicking on the clear icon.' + }, { name: 'virtualScrollerOptions', type: 'object', diff --git a/components/lib/dropdown/BaseDropdown.vue b/components/lib/dropdown/BaseDropdown.vue index 755a63ccb4..bd4168458f 100644 --- a/components/lib/dropdown/BaseDropdown.vue +++ b/components/lib/dropdown/BaseDropdown.vue @@ -106,6 +106,10 @@ export default { type: Boolean, default: false }, + resetFilterOnClear: { + type: Boolean, + default: false + }, virtualScrollerOptions: { type: Object, default: null diff --git a/components/lib/dropdown/Dropdown.d.ts b/components/lib/dropdown/Dropdown.d.ts index 3e86a0347b..e301e1b14b 100755 --- a/components/lib/dropdown/Dropdown.d.ts +++ b/components/lib/dropdown/Dropdown.d.ts @@ -389,6 +389,11 @@ export interface DropdownProps { * @defaultValue false */ resetFilterOnHide?: boolean; + /** + * Clears the filter value when clicking on the clear icon. + * @defaultValue false + */ + resetFilterOnClear?: boolean; /** * Whether to use the virtualScroller feature. The properties of VirtualScroller component can be used like an object in it. */ diff --git a/components/lib/dropdown/Dropdown.vue b/components/lib/dropdown/Dropdown.vue index dd5613d6a2..ec072002cd 100755 --- a/components/lib/dropdown/Dropdown.vue +++ b/components/lib/dropdown/Dropdown.vue @@ -421,7 +421,7 @@ export default { }, onClearClick(event) { this.updateModel(event, null); - this.filterValue = null; + this.resetFilterOnClear && (this.filterValue = null); }, onFirstHiddenFocus(event) { const focusableEl = event.relatedTarget === this.$refs.focusInput ? DomHandler.getFirstFocusableElement(this.overlay, ':not([data-p-hidden-focusable="true"])') : this.$refs.focusInput; diff --git a/doc/common/apidoc/index.json b/doc/common/apidoc/index.json index 46068b4df4..6fe93ac46c 100644 --- a/doc/common/apidoc/index.json +++ b/doc/common/apidoc/index.json @@ -24170,6 +24170,14 @@ "default": "false", "description": "Clears the filter value when hiding the dropdown." }, + { + "name": "resetFilterOnClear", + "optional": true, + "readonly": false, + "type": "boolean", + "default": "false", + "description": "Clears the filter value when clicking on the dropdown." + }, { "name": "virtualScrollerOptions", "optional": true,