From 3e4ade6039fed04199ebd9e52d5e57145e2807b6 Mon Sep 17 00:00:00 2001 From: esikkala <esko.ikkala@aalto.fi> Date: Thu, 13 Jun 2019 13:52:59 +0300 Subject: [PATCH] Hierarchical facet: if a child has been previously selected, remove it --- src/client/components/facet_bar/HierarchicalFacet.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/client/components/facet_bar/HierarchicalFacet.js b/src/client/components/facet_bar/HierarchicalFacet.js index b403a6e4..371939d1 100644 --- a/src/client/components/facet_bar/HierarchicalFacet.js +++ b/src/client/components/facet_bar/HierarchicalFacet.js @@ -150,6 +150,15 @@ class HierarchicalFacet extends Component { recursiveSelect = (nodes, selected) => { nodes.forEach(node => { + // if a child has been previously selected, remove it + if (has(this.props.facet.uriFilter, node.id)) { + this.props.updateFacetOption({ + facetClass: this.props.facetClass, + facetID: this.props.facetID, + option: this.props.facet.filterType, + value: { node } + }); + } node.selected = selected ? 'true' : 'false'; node.disabled = selected ? 'true' : 'false'; if (has(node, 'children')) { @@ -159,7 +168,6 @@ class HierarchicalFacet extends Component { return nodes; }; - handleCheckboxChange = treeObj => () => { this.props.updateFacetOption({ facetClass: this.props.facetClass, -- GitLab