codeant-ai-for-open-source[bot] commented on code in PR #35777:
URL: https://github.com/apache/superset/pull/35777#discussion_r3943104957


##########
superset-frontend/src/components/Chart/ChartRenderer.jsx:
##########
@@ -89,14 +89,37 @@ class ChartRenderer extends Component {
     const suppressContextMenu = getChartMetadataRegistry().get(
       props.formData.viz_type ?? props.vizType,
     )?.suppressContextMenu;
+
+    // Load legend state from sessionStorage (per-chart)
+    const legendStateKey = `chart_legend_state_${props.chartId}`;
+    const legendIndexKey = `chart_legend_index_${props.chartId}`;
+    let savedLegendState = null;
+    let savedLegendIndex = 0;
+    try {
+      const storedState = sessionStorage.getItem(legendStateKey);
+      if (storedState !== null) {
+        savedLegendState = JSON.parse(storedState);
+      }
+      const storedIndex = sessionStorage.getItem(legendIndexKey);
+      if (storedIndex !== null) {
+        console.log(storedIndex);
+        savedLegendIndex = JSON.parse(storedIndex);
+      }
+    } catch (e) {
+      logging.warn(
+        '[ChartRenderer] Failed to load legend state from sessionStorage:',
+        e,
+      );

Review Comment:
   ✅ **Customized review instruction saved!**
   
   **Instruction:**
   > Do not require an additional typeof window guard for browser storage 
access in this component when the access is already protected by try/catch; 
this frontend does not use SSR.
   
   **Applied to:**
     - `superset-frontend/src/components/Chart/ChartRenderer.jsx`
   
   ---
   💡 *To manage or update this instruction, visit: [CodeAnt AI 
Settings](https://app.codeant.ai/org/settings/learnings)*



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to