SBIN2010 commented on code in PR #45589:
URL: https://github.com/apache/superset/pull/45589#discussion_r4353497792
##########
superset-frontend/src/pages/Home/index.tsx:
##########
@@ -214,12 +219,17 @@ function Welcome({ user, addDangerToast }: WelcomeProps) {
useEffect(() => {
if (!otherTabFilters || WelcomeMainExtension) {
- return;
+ return undefined;
}
+ // Guards against out-of-order responses: if `refreshKey` changes again
+ // (e.g. a rapid follow-up delete) before this run's requests resolve,
+ // its results are discarded instead of overwriting newer state.
+ let isStale = false;
const activeTab = getItem(LocalStorageKeys.HomepageActivityFilter, null);
Review Comment:
Each refresh snapshots HomepageActivityFilter here and applies it with
setActiveChild when the request settles (lines 238–244). Changing the Recents
tab does not bump refreshKey, so isStale does not cover that case.
If Recents is showing Viewed, the user deletes a chart, then opens Created
before this request resolves, the response switches them back to Viewed.
Keep the initial-tab selection on the first load. When refreshKey changes,
update activityData only.
##########
superset-frontend/src/pages/Home/index.tsx:
##########
@@ -214,12 +219,17 @@ function Welcome({ user, addDangerToast }: WelcomeProps) {
useEffect(() => {
if (!otherTabFilters || WelcomeMainExtension) {
- return;
+ return undefined;
}
+ // Guards against out-of-order responses: if `refreshKey` changes again
+ // (e.g. a rapid follow-up delete) before this run's requests resolve,
+ // its results are discarded instead of overwriting newer state.
+ let isStale = false;
const activeTab = getItem(LocalStorageKeys.HomepageActivityFilter, null);
setActiveState(collapseState.length > 0 ? collapseState : DEFAULT_TAB_ARR);
Review Comment:
setActiveState runs on every refreshKey change. collapseState is read from
HomepageCollapseState, and handleCollapse persists [] when every panel is
collapsed. collapseState.length > 0 ? collapseState : DEFAULT_TAB_ARR treats
that empty array as "no saved preference" and forces ['dashboards', 'charts'].
Previously this effect ran once, when Home mounted, so a user who collapsed
the sections stayed collapsed. A delete now reopens Dashboards and Charts.
Apply this restore only on the initial load (refreshKey === 0). Later runs
should refresh activity data and leave activeState alone.
--
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]