From bacc0585ee1ed02fab97a37efdebd3a76d5b461a Mon Sep 17 00:00:00 2001 From: eireland Date: Mon, 29 Jan 2024 08:13:50 -0800 Subject: [PATCH 1/2] Fixes attribute selection after All has been selected --- src/components/attribute-selector.tsx | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/components/attribute-selector.tsx b/src/components/attribute-selector.tsx index 1723933..4601820 100644 --- a/src/components/attribute-selector.tsx +++ b/src/components/attribute-selector.tsx @@ -49,18 +49,18 @@ export const AttributesSelector = () => { const toggleAttributeSelect = (e: React.MouseEvent) => { const selectedAttrName = e.currentTarget.textContent; const selectedAttr = attributeList.find(a => a.name === selectedAttrName); + console.log("selectedAttr", selectedAttr, selectedAttrName); const filters = selectedAttrsAndFiltersForFrequency.filters; setState(draft => { const draftAttrNames = draft.frequencies[selectedFrequency].attrs.map(a => {return a.name;}); if (allSelected) { setAllSelected(false); draft.frequencies[selectedFrequency] = {attrs: [], filters}; - selectedAttr && draft.frequencies[selectedFrequency].attrs.push(selectedAttr); - } - if (selectedAttrName) { - const attrIndex = draftAttrNames.indexOf(selectedAttrName); - if (selectedAttr) { + selectedAttr !== undefined && draft.frequencies[selectedFrequency].attrs.push(selectedAttr); + } else if (selectedAttrName) { + if (selectedAttr !== undefined) { if (draftAttrNames.includes(selectedAttrName)) { + const attrIndex = draftAttrNames.indexOf(selectedAttrName); if (attrIndex !== null) { draft.frequencies[selectedFrequency].attrs.splice(attrIndex, 1); } @@ -69,6 +69,7 @@ export const AttributesSelector = () => { } } } + console.log("draft.frequencies[selectedFrequency].attrs", draft.frequencies[selectedFrequency].attrs); }); }; From cc2f503debda01503945bb60deb08c03d4cdc52f Mon Sep 17 00:00:00 2001 From: eireland Date: Mon, 29 Jan 2024 12:14:30 -0800 Subject: [PATCH 2/2] removes console.log --- src/components/attribute-selector.tsx | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/components/attribute-selector.tsx b/src/components/attribute-selector.tsx index 4601820..7035602 100644 --- a/src/components/attribute-selector.tsx +++ b/src/components/attribute-selector.tsx @@ -49,7 +49,6 @@ export const AttributesSelector = () => { const toggleAttributeSelect = (e: React.MouseEvent) => { const selectedAttrName = e.currentTarget.textContent; const selectedAttr = attributeList.find(a => a.name === selectedAttrName); - console.log("selectedAttr", selectedAttr, selectedAttrName); const filters = selectedAttrsAndFiltersForFrequency.filters; setState(draft => { const draftAttrNames = draft.frequencies[selectedFrequency].attrs.map(a => {return a.name;}); @@ -69,7 +68,6 @@ export const AttributesSelector = () => { } } } - console.log("draft.frequencies[selectedFrequency].attrs", draft.frequencies[selectedFrequency].attrs); }); };