- {actionValues
- .sort((a, b) => {
- // sort the view actions to the front
- if (a.action.keyword !== b.action.keyword) {
- return a.action.keyword === 'view' ? -1 : b.action.keyword === 'view' ? 1 : 0;
- }
+ {actionValues &&
+ actionValues
+ .sort((a, b) => {
+ // sort the view actions to the front
+ if (a.action.keyword !== b.action.keyword) {
+ return a.action.keyword === 'view' ? -1 : b.action.keyword === 'view' ? 1 : 0;
+ }
- // then sort by filter display value
- const aDisplayValue = a.displayValue ?? a.value;
- const bDisplayValue = b.displayValue ?? b.value;
- return aDisplayValue > bDisplayValue ? 1 : aDisplayValue < bDisplayValue ? -1 : 0;
- })
- .map((actionValue, index) => {
- // loop over all actionValues so that the index remains consistent, but don't show sort actions
- if (actionValue.action.keyword === 'sort') {
- return null;
- }
+ // then sort by filter display value
+ const aDisplayValue = a.displayValue ?? a.value;
+ const bDisplayValue = b.displayValue ?? b.value;
+ return aDisplayValue > bDisplayValue ? 1 : aDisplayValue < bDisplayValue ? -1 : 0;
+ })
+ .map((actionValue, index) => {
+ // loop over all actionValues so that the index remains consistent, but don't show sort actions
+ if (actionValue.action.keyword === 'sort') {
+ return null;
+ }
- // only FilterActions can be edited via click
- const _onClick = actionValue.action.keyword === 'filter' ? onClick : undefined;
- // search and filter actions can be removed via click
- const _onRemove =
- actionValue.action.keyword === 'filter' || actionValue.action.keyword === 'search'
- ? onRemove
- : undefined;
+ // only FilterActions can be edited via click
+ const _onClick = actionValue.action.keyword === 'filter' ? onClick : undefined;
+ // search and filter actions can be removed via click
+ const _onRemove =
+ actionValue.action.keyword === 'filter' || actionValue.action.keyword === 'search'
+ ? onRemove
+ : undefined;
- return (
-
- );
- })}
+ return (
+
+ );
+ })}
+
+ {onAddFilterClick && (
+
+ )}
{onRemoveAll && showRemoveAll && (
Remove all
@@ -63,3 +80,4 @@ export const FilterStatus: FC = memo(props => {
);
});
+FilterStatus.displayName = 'FilterStatus';