From 7d2e9629661e9dc43ca8810326e93c448e533c10 Mon Sep 17 00:00:00 2001 From: codebyalex Date: Mon, 18 Mar 2019 20:56:24 -0400 Subject: [PATCH] fixed failing scenario: If parent is not set to true but some sub toggles are set to true a user should be able to set the parent toggle to true and make all subs true (with intervention) --- .../src/components/Report/HighlightToggle.tsx | 35 +++++++++++++------ 1 file changed, 25 insertions(+), 10 deletions(-) diff --git a/addons/a11y/src/components/Report/HighlightToggle.tsx b/addons/a11y/src/components/Report/HighlightToggle.tsx index 181ac13c101..b24ac1aaa5b 100644 --- a/addons/a11y/src/components/Report/HighlightToggle.tsx +++ b/addons/a11y/src/components/Report/HighlightToggle.tsx @@ -171,16 +171,31 @@ class HighlightToggle extends Component { } onToggle(): void { - for (let element of this.props.elementsToHighlight) { - const targetElement = getTargetElement(element.target[0]); - this.higlightRuleLocation(targetElement, !this.props.isToggledOn); - if (this.props.highlightedElementsMap.get(targetElement)) { - this.saveElementDataToMap( - targetElement, - !this.props.highlightedElementsMap.get(targetElement).isHighlighted, - this.props.highlightedElementsMap.get(targetElement).originalOutline, - this.props.type - ); + if(this.props.isToggledOn){ + for (let element of this.props.elementsToHighlight) { + const targetElement = getTargetElement(element.target[0]); + if(this.props.highlightedElementsMap.get(targetElement) && this.props.highlightedElementsMap.get(targetElement).isHighlighted){ + this.higlightRuleLocation(targetElement, false); + this.saveElementDataToMap( + targetElement, + false, + this.props.highlightedElementsMap.get(targetElement).originalOutline, + this.props.type + ); + } + } + } else { + for (let element of this.props.elementsToHighlight) { + const targetElement = getTargetElement(element.target[0]); + if(this.props.highlightedElementsMap.get(targetElement) && !this.props.highlightedElementsMap.get(targetElement).isHighlighted){ + this.higlightRuleLocation(targetElement, true); + this.saveElementDataToMap( + targetElement, + true, + this.props.highlightedElementsMap.get(targetElement).originalOutline, + this.props.type + ); + } } } }