Skip to content

Commit

Permalink
fix: primefaces#5060, Dropdown: After selecting an option, clearing t…
Browse files Browse the repository at this point in the history
…he value using close icon should clear the filter input
  • Loading branch information
akshayantony55 committed Jan 15, 2024
1 parent fa50897 commit e1a6d4e
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 1 deletion.
6 changes: 6 additions & 0 deletions api-generator/components/dropdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
4 changes: 4 additions & 0 deletions components/lib/dropdown/BaseDropdown.vue
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,10 @@ export default {
type: Boolean,
default: false
},
resetFilterOnClear: {
type: Boolean,
default: false
},
virtualScrollerOptions: {
type: Object,
default: null
Expand Down
5 changes: 5 additions & 0 deletions components/lib/dropdown/Dropdown.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand Down
2 changes: 1 addition & 1 deletion components/lib/dropdown/Dropdown.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
8 changes: 8 additions & 0 deletions doc/common/apidoc/index.json
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit e1a6d4e

Please sign in to comment.