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 9f5727777b..ec072002cd 100755 --- a/components/lib/dropdown/Dropdown.vue +++ b/components/lib/dropdown/Dropdown.vue @@ -421,6 +421,7 @@ export default { }, onClearClick(event) { this.updateModel(event, 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, diff --git a/doc/dropdown/FilterDoc.vue b/doc/dropdown/FilterDoc.vue index dd7df8d72c..6723d73b89 100644 --- a/doc/dropdown/FilterDoc.vue +++ b/doc/dropdown/FilterDoc.vue @@ -3,7 +3,7 @@

Dropdown provides built-in filtering that is enabled by adding the filter property.

- +