msyavuz commented on code in PR #35265:
URL: https://github.com/apache/superset/pull/35265#discussion_r2524944360


##########
superset-frontend/src/dashboard/components/gridComponents/Tab/Tab.jsx:
##########
@@ -113,6 +114,49 @@ const renderDraggableContent = dropProps =>
 const Tab = props => {
   const dispatch = useDispatch();
   const canEdit = useSelector(state => state.dashboardInfo.dash_edit_perm);
+  const dashboardLayout = useSelector(state => state.dashboardLayout.present);
+  const lastRefreshTime = useSelector(
+    state => state.dashboardState.lastRefreshTime,
+  );
+  const tabActivationTimes = useSelector(
+    state => state.dashboardState.tabActivationTimes || {},
+  );
+  const dashboardInfo = useSelector(state => state.dashboardInfo);
+
+  // Check if tab needs refresh when it becomes visible
+  useEffect(() => {
+    if (props.renderType === RENDER_TAB_CONTENT && props.isComponentVisible) {
+      const tabId = props.id;
+      const tabActivationTime = tabActivationTimes[tabId] || 0;
+
+      // If a refresh occurred while this tab was inactive,
+      // refresh the charts in this tab now that it's visible
+      if (
+        lastRefreshTime &&
+        tabActivationTime &&
+        lastRefreshTime > tabActivationTime
+      ) {
+        const chartIds = getChartIdsFromComponent(tabId, dashboardLayout);
+        if (chartIds.length > 0) {
+          // Small delay to ensure charts are fully mounted
+          setTimeout(() => {
+            // Refresh charts in this tab
+            dispatch(onRefresh(chartIds, true, 0, dashboardInfo.id));
+          }, 100);
+        }
+      }
+    }
+  }, [
+    props.isComponentVisible,
+    props.renderType,
+    props.id,
+    lastRefreshTime,
+    tabActivationTimes,
+    dashboardLayout,
+    dashboardInfo.id,

Review Comment:
   I don't see any issues from manual testing



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