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

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

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

---------

Co-authored-by: Akshay Antony <akshayantony55@gmail.com>
pull/5098/head
akshayaqburst 2024-01-16 16:45:32 +05:30 committed by GitHub
parent 6b75f1a565
commit 6f71f8195e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 25 additions and 1 deletions

View File

@ -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',

View File

@ -106,6 +106,10 @@ export default {
type: Boolean,
default: false
},
resetFilterOnClear: {
type: Boolean,
default: false
},
virtualScrollerOptions: {
type: Object,
default: null

View File

@ -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.
*/

View File

@ -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;

View File

@ -24158,6 +24158,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,

View File

@ -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" />