AG-20897 - Fixed bug with checkbox's actual state on filter adding.

Updates#5647

Squashed commit of the following:

commit 610f4dae6f7e0e2576669489030eb43bd06d6da6
Merge: fb0c0472 c1924a8b
Author: Artem Krisanov <a.krisanov@adguard.com>
Date:   Tue Apr 11 18:16:44 2023 +0300

    Merge branch 'master' of ssh://bit.adguard.com:7999/dns/adguard-home into 5647-filter-adding

commit fb0c04725c41707ca6a1e4ce36a8e17a6898ee27
Author: Artem Krisanov <a.krisanov@adguard.com>
Date:   Mon Apr 10 16:51:45 2023 +0300

    Fixed bug with checkbox's actual state on filter adding.
This commit is contained in:
Artem Krisanov 2023-04-11 18:39:46 +03:00
parent c1924a8b8a
commit 6da7392345
1 changed files with 7 additions and 3 deletions

View File

@ -12,7 +12,6 @@ import { MODAL_TYPE } from '../../helpers/constants';
import {
getCurrentFilter,
getObjDiff,
} from '../../helpers/helpers';
import filtersCatalog from '../../helpers/filters/filters';
@ -22,7 +21,7 @@ class DnsBlocklist extends Component {
this.props.getFilteringStatus();
}
handleSubmit = (values, _, { initialValues }) => {
handleSubmit = (values) => {
const { modalFilterUrl, modalType } = this.props.filtering;
switch (modalType) {
@ -35,7 +34,12 @@ class DnsBlocklist extends Component {
break;
}
case MODAL_TYPE.CHOOSE_FILTERING_LIST: {
const changedValues = getObjDiff(initialValues, values);
const changedValues = Object.entries(values)?.reduce((acc, [key, value]) => {
if (value && key in filtersCatalog.filters) {
acc[key] = value;
}
return acc;
}, {});
Object.keys(changedValues)
.forEach((fieldName) => {