rusackas commented on code in PR #35777:
URL: https://github.com/apache/superset/pull/35777#discussion_r2519420426


##########
superset-frontend/src/components/Chart/ChartRenderer.jsx:
##########
@@ -32,8 +32,72 @@ import {
 import { Logger, LOG_ACTIONS_RENDER_CHART } from 'src/logger/LogUtils';
 import { EmptyState } from '@superset-ui/core/components';
 import { ChartSource } from 'src/types/ChartSource';
+import { setItem, getItem } from 'src/utils/localStorageHelpers';
 import ChartContextMenu from './ChartContextMenu/ChartContextMenu';
 
+// Global pathname tracker to detect page navigation
+let globalCleanupPathname = '';
+
+/**
+ * Clean up ALL chart legend states from localStorage (including unmounted 
charts)
+ */
+export function cleanupAllChartLegendStates() {
+  try {
+    // Get all localStorage keys
+    const keysToRemove = [];
+    for (let i = 0; i < localStorage.length; i += 1) {
+      const key = localStorage.key(i);
+      if (
+        key &&
+        (key.startsWith('chart_legend_state_') ||
+          key.startsWith('chart_legend_index_'))
+      ) {
+        keysToRemove.push(key);
+      }
+    }
+    // Remove all chart legend state keys
+    keysToRemove.forEach(key => {
+      localStorage.removeItem(key);
+    });
+  } catch (e) {
+    console.warn(
+      'Failed to clean up all chart legend states from localStorage:',

Review Comment:
   Yep! This will remove a linter warning, which is nice :)



-- 
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