From 6da739234553965b22d6bcd7d4dd3f91e2f035ac Mon Sep 17 00:00:00 2001 From: Artem Krisanov Date: Tue, 11 Apr 2023 18:39:46 +0300 Subject: [PATCH] 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 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 Date: Mon Apr 10 16:51:45 2023 +0300 Fixed bug with checkbox's actual state on filter adding. --- client/src/components/Filters/DnsBlocklist.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/client/src/components/Filters/DnsBlocklist.js b/client/src/components/Filters/DnsBlocklist.js index c4facadc..d1f020f1 100644 --- a/client/src/components/Filters/DnsBlocklist.js +++ b/client/src/components/Filters/DnsBlocklist.js @@ -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) => {