activate filter on !!val and clear val on !filter
This commit is contained in:
parent
3233b46aec
commit
5a9f7cbaa1
2 changed files with 4 additions and 3 deletions
|
@ -165,13 +165,14 @@ const FilterContent: React.FC<FilterContentProps> = ({
|
||||||
filter: IFilterElement<string>
|
filter: IFilterElement<string>
|
||||||
) {
|
) {
|
||||||
const switchToActive = action.payload.update.active;
|
const switchToActive = action.payload.update.active;
|
||||||
|
|
||||||
if (switchToActive && filter.name !== openedFilter?.name) {
|
if (switchToActive && filter.name !== openedFilter?.name) {
|
||||||
handleFilterAttributeFocus(filter);
|
handleFilterAttributeFocus(filter);
|
||||||
} else if (!switchToActive && filter.name === openedFilter?.name) {
|
} else if (!switchToActive && filter.name === openedFilter?.name) {
|
||||||
handleFilterAttributeFocus(undefined);
|
handleFilterAttributeFocus(undefined);
|
||||||
}
|
}
|
||||||
|
if (!switchToActive) {
|
||||||
|
action.payload.update.value = [];
|
||||||
|
}
|
||||||
onFilterPropertyChange(action);
|
onFilterPropertyChange(action);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -179,7 +180,6 @@ const FilterContent: React.FC<FilterContentProps> = ({
|
||||||
action: FilterReducerAction<T>
|
action: FilterReducerAction<T>
|
||||||
) {
|
) {
|
||||||
const { update } = action.payload;
|
const { update } = action.payload;
|
||||||
|
|
||||||
onFilterPropertyChange({
|
onFilterPropertyChange({
|
||||||
...action,
|
...action,
|
||||||
payload: { ...action.payload, update: { ...update, active: true } }
|
payload: { ...action.payload, update: { ...update, active: true } }
|
||||||
|
|
|
@ -32,6 +32,7 @@ const FilterOptionField: React.FC<FilterBaseFieldProps> = ({
|
||||||
payload: {
|
payload: {
|
||||||
name: filterField.name,
|
name: filterField.name,
|
||||||
update: {
|
update: {
|
||||||
|
active: true,
|
||||||
value: filterField.multiple
|
value: filterField.multiple
|
||||||
? toggle(value, filterField.value, (a, b) => a === b)
|
? toggle(value, filterField.value, (a, b) => a === b)
|
||||||
: [value]
|
: [value]
|
||||||
|
|
Loading…
Reference in a new issue