]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-13144 Fix unslection on multi-location issues.
authorMathieu Suen <mathieu.suen@sonarsource.com>
Tue, 3 Mar 2020 14:27:41 +0000 (15:27 +0100)
committersonartech <sonartech@sonarsource.com>
Wed, 4 Mar 2020 20:03:58 +0000 (20:03 +0000)
server/sonar-web/src/main/js/apps/issues/crossComponentSourceViewer/ComponentSourceSnippetViewer.tsx
server/sonar-web/src/main/js/apps/issues/crossComponentSourceViewer/__tests__/ComponentSourceSnippetViewer-test.tsx

index 54ef42fb0c3bb024a663b9903bfaa5fbc430c9f6..5519d70d6b32d9d0c5cabcf542d1bbeab1949238 100644 (file)
@@ -290,8 +290,13 @@ export default class ComponentSourceSnippetViewer extends React.PureComponent<Pr
     }));
   };
 
-  handleSymbolClick = (highlightedSymbols: string[]) => {
-    this.setState({ highlightedSymbols });
+  handleSymbolClick = (clickedSymbols: string[]) => {
+    this.setState(({ highlightedSymbols }) => {
+      const newHighlightedSymbols = clickedSymbols.filter(
+        symb => !highlightedSymbols.includes(symb)
+      );
+      return { highlightedSymbols: newHighlightedSymbols };
+    });
   };
 
   loadDuplications = (line: T.SourceLine) => {
index 331f5b1d2b8d9486311b460fbe2efc99753f2fb7..70382f6c53da6371380aee4da389e46773e8af0b 100644 (file)
@@ -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', () => {