
SelectedFilters creates a selectable filter UI view displaying the current selected values from other components. This component is useful for improving selection accessibility of other components.
Example uses:
- displaying all the user selected facet filters together in the main view area for better accessibility.
- building mobile responsive views where it is not practical to show all the UI components in the main view.
Usage
Basic Usage
<template>
<selected-filters />
</template>Usage with All Props
<selected-filters
clearAllLabel="Clear filters"
:showClearAll="true"
/>Props
-
showClearAll
boolean[optional] (defaults totrue) When set totrue, displays an additional button to clear all the filters -
clearAllLabel
string[optional] (defaults to'Clear All') Sets the label for the clear all button. -
title
string[optional] Can be used to set a title -
resetToDefault
boolean[optional] When set to true and clearAll functionality is utilised, then it would set the filter's value to its default set value(thedefaultValueprop) instead of null/ undefined. Defaults tofalse. -
resetToValues
Object[optional] It is a map ofcomponentIdto the component's value which would be used to set the component's value whenclearAllaction gets called. For example, the following configuration would reset theAuthorFiltertoNora RobertsonclearAllaction.<selected-filters :resetToValues="{ 'AuthorFilter': ['Nora Roberts'] }" > -
clearAllBlacklistComponents
Array[optional] allows defining a list of component IDs, which would reset their values whenclearAllaction gets triggered.The following example instructs the
SelectedFilterscomponent to not reset thesearchboxcomponent's value whenclearAllbutton is clicked by the user.<selected-filters :clearAllBlacklistComponents="['searchbox']" >Note: The
clearAllBlacklistComponentsprop has priority overresetToValuesandresetToDefaultprops which means component would retain its current value and would ignore the values defined inresetToValuesmap ordefaultValueprop.
Most ReactiveSearch filter components have a prop showFilter (defaults to true) which can be used to control whether the component's selected state appears in the SelectedFilters component. There is also a filterLabel prop which controls how that component is displayed.
Note
The
showFilterandfilterLabelprop updates are only reflected if the underlying query of the associated component has changed.
As an example, check MultiList usage to see how showFilter and filterLabel can be used.
Events
- change
function[optional] Provides access to the current selected values. This enables you to retrieve the selected filters and current search state in a convenient way. - clear
function[optional] a callback function which will be called when a particular filter(value) has been removed from the selected filters, provides thecomponentandvalue.
Styles
SelectedFilters component supports innerClass prop with the following keys:
button
Read more about it here.
Extending
SelectedFilters component can be extended to customize the look and feel with className.
<selected-filters className="custom-class" />-
className
StringCSS class to be injected on the component container. -
slot-scope ( Default Slot ) Enables custom rendering for SelectedFilters component. It provides an object as a param which contains all the props needed to render the custom selected-filters, including the functions to clear and update the component values. You can find the example at here.
It accepts an object with these properties:
components:Array<String>array ofcomponentIds which have gotshowFilterset totrue.selectedValues:Objectmap of components' Ids and their updated values.clearValues:Function - () => voidfunction to clear all selected filters.clearValue:Function - (String) => voidfunction to clear a selected filter's value. It takes thecomponentIdas a param.setValue:Function - (String, Any) => voidfunction to set a component's value. It takes thecomponentIdandvalue(to set) as parameters.resetValuesToDefault:Function - (Array<String>) => voidfunction to reset values of the selected filters to their default values. It accepts an Array of componentIds to avoid resetting their values.