From 041696c1ddfaa124b3f6ee2680ca8d08d3001e47 Mon Sep 17 00:00:00 2001 From: Mathieu Suen Date: Tue, 3 Mar 2020 15:27:41 +0100 Subject: [PATCH] SONAR-13144 Fix unslection on multi-location issues. --- .../ComponentSourceSnippetViewer.tsx | 9 +++++++-- .../__tests__/ComponentSourceSnippetViewer-test.tsx | 2 ++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/server/sonar-web/src/main/js/apps/issues/crossComponentSourceViewer/ComponentSourceSnippetViewer.tsx b/server/sonar-web/src/main/js/apps/issues/crossComponentSourceViewer/ComponentSourceSnippetViewer.tsx index 54ef42fb0c3..5519d70d6b3 100644 --- a/server/sonar-web/src/main/js/apps/issues/crossComponentSourceViewer/ComponentSourceSnippetViewer.tsx +++ b/server/sonar-web/src/main/js/apps/issues/crossComponentSourceViewer/ComponentSourceSnippetViewer.tsx @@ -290,8 +290,13 @@ export default class ComponentSourceSnippetViewer extends React.PureComponent { - this.setState({ highlightedSymbols }); + handleSymbolClick = (clickedSymbols: string[]) => { + this.setState(({ highlightedSymbols }) => { + const newHighlightedSymbols = clickedSymbols.filter( + symb => !highlightedSymbols.includes(symb) + ); + return { highlightedSymbols: newHighlightedSymbols }; + }); }; loadDuplications = (line: T.SourceLine) => { diff --git a/server/sonar-web/src/main/js/apps/issues/crossComponentSourceViewer/__tests__/ComponentSourceSnippetViewer-test.tsx b/server/sonar-web/src/main/js/apps/issues/crossComponentSourceViewer/__tests__/ComponentSourceSnippetViewer-test.tsx index 331f5b1d2b8..70382f6c53d 100644 --- a/server/sonar-web/src/main/js/apps/issues/crossComponentSourceViewer/__tests__/ComponentSourceSnippetViewer-test.tsx +++ b/server/sonar-web/src/main/js/apps/issues/crossComponentSourceViewer/__tests__/ComponentSourceSnippetViewer-test.tsx @@ -168,6 +168,8 @@ it('should handle symbol highlighting', () => { expect(wrapper.state('highlightedSymbols')).toEqual([]); wrapper.instance().handleSymbolClick(['foo']); expect(wrapper.state('highlightedSymbols')).toEqual(['foo']); + wrapper.instance().handleSymbolClick(['foo']); + expect(wrapper.state('highlightedSymbols')).toEqual([]); }); it('should correctly handle lines actions', () => { -- 2.39.5