Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Primefaces#5060, Dropdown: After selecting an option, clearing the value using close icon should clear the filter input #5061

Merged
merged 2 commits into from
Jan 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
1 change: 1 addition & 0 deletions components/lib/dropdown/Dropdown.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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;
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
2 changes: 1 addition & 1 deletion doc/dropdown/FilterDoc.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<p>Dropdown provides built-in filtering that is enabled by adding the <i>filter</i> property.</p>
</DocSectionText>
<div class="card flex justify-content-center">
<Dropdown v-model="selectedCountry" :options="countries" filter optionLabel="name" placeholder="Select a Country" class="w-full md:w-14rem">
<Dropdown v-model="selectedCountry" :options="countries" filter optionLabel="name" placeholder="Select a Country" class="w-full md:w-14rem" showClear>
<template #value="slotProps">
<div v-if="slotProps.value" class="flex align-items-center">
<img :alt="slotProps.value.label" src="https://primefaces.org/cdn/primevue/images/flag/flag_placeholder.png" :class="`mr-2 flag flag-${slotProps.value.code.toLowerCase()}`" style="width: 18px" />
Expand Down
Loading