diff --git a/CHANGELOG.md b/CHANGELOG.md index fef392b7a..1606a95f5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,12 @@ # Snyk Security - Code and Open Source Dependencies Changelog +## [2.2.1] + +### Fixed + +- Snyk Code: Optimized performance by caching DOM element references in `suggestion-details`. This minimizes repetitive DOM queries, enhancing the responsiveness and efficiency of the webview. +- Snyk Code: Corrected the visibility toggling behavior in the `#suggestion-details` section. Replaced inline styling with CSS class-based approach. + ## [2.2.0] ### Added diff --git a/src/snyk/snykCode/views/suggestion/codeSuggestionWebviewProvider.ts b/src/snyk/snykCode/views/suggestion/codeSuggestionWebviewProvider.ts index b54ce499c..def7b6614 100644 --- a/src/snyk/snykCode/views/suggestion/codeSuggestionWebviewProvider.ts +++ b/src/snyk/snykCode/views/suggestion/codeSuggestionWebviewProvider.ts @@ -291,7 +291,7 @@ export class CodeSuggestionWebviewProvider -
+
diff --git a/src/snyk/snykCode/views/suggestion/codeSuggestionWebviewScript.ts b/src/snyk/snykCode/views/suggestion/codeSuggestionWebviewScript.ts index d15eb5ba1..9370c9534 100644 --- a/src/snyk/snykCode/views/suggestion/codeSuggestionWebviewScript.ts +++ b/src/snyk/snykCode/views/suggestion/codeSuggestionWebviewScript.ts @@ -58,6 +58,12 @@ declare const acquireVsCodeApi: any; const vscode = acquireVsCodeApi(); + const elements = { + readMoreBtn: document.querySelector('.read-more-btn') as HTMLElement, + suggestionDetails: document.querySelector('#suggestion-details') as HTMLElement, + suggestionDetailsContent: document.querySelector('.suggestion-details-content') as HTMLElement, + }; + let isReadMoreBtnEventBound = false; function navigateToUrl(url: string) { @@ -321,17 +327,18 @@ declare const acquireVsCodeApi: any; } function showSuggestionDetails(suggestion: Suggestion) { - const suggestionDetails = document.querySelector('#suggestion-details') as HTMLElement; - const readMoreBtn = document.querySelector('.read-more-btn') as HTMLElement; + const { suggestionDetails, readMoreBtn, suggestionDetailsContent } = elements; if (!suggestion || !suggestion.text || !suggestionDetails || !readMoreBtn) { + readMoreBtn.classList.add('hidden'); + suggestionDetailsContent.classList.add('hidden'); return; } suggestionDetails.innerHTML = suggestion.text; suggestionDetails.classList.add('collapsed'); - - readMoreBtn.style.display = 'block'; + readMoreBtn.classList.remove('hidden'); + suggestionDetailsContent.classList.remove('hidden'); if (!isReadMoreBtnEventBound) { readMoreBtn.addEventListener('click', () => {