You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@superset.apache.org by jl...@apache.org on 2026/08/25 18:32:32 UTC
(superset) branch master updated: fix(explore): skip re-fetch when navigating away from /explore (#39506)
This is an automated email from the ASF dual-hosted git repository.
sadpandajoe pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/superset.git
The following commit(s) were added to refs/heads/master by this push:
new fc4d7221ecb fix(explore): skip re-fetch when navigating away from /explore (#39506)
fc4d7221ecb is described below
commit fc4d7221ecbf48f55bc59a6654b87be0e88b1320
Author: Maxime Beauchemin <ma...@gmail.com>
AuthorDate: Tue Aug 25 11:32:25 2026 -0700
fix(explore): skip re-fetch when navigating away from /explore (#39506)
Co-authored-by: sadpandajoe <jc...@gmail.com>
---
superset-frontend/src/pages/Chart/Chart.test.tsx | 48 ++++++++++++++++++------
superset-frontend/src/pages/Chart/index.tsx | 10 +++++
2 files changed, 47 insertions(+), 11 deletions(-)
diff --git a/superset-frontend/src/pages/Chart/Chart.test.tsx b/superset-frontend/src/pages/Chart/Chart.test.tsx
index 3ead8f44dc1..a101fb53e90 100644
--- a/superset-frontend/src/pages/Chart/Chart.test.tsx
+++ b/superset-frontend/src/pages/Chart/Chart.test.tsx
@@ -223,7 +223,7 @@ describe('ChartPage', () => {
window.history.pushState(
{},
'',
- `/?${URL_PARAMS.dashboardPageId.name}=${dashboardPageId}`,
+ `/explore/?${URL_PARAMS.dashboardPageId.name}=${dashboardPageId}`,
);
const { getByTestId } = render(<ChartPage />, {
useRouter: true,
@@ -261,13 +261,13 @@ describe('ChartPage', () => {
window.history.pushState(
{},
'',
- `/?${URL_PARAMS.dashboardPageId.name}=${dashboardPageId}`,
+ `/explore/?${URL_PARAMS.dashboardPageId.name}=${dashboardPageId}`,
);
const { getByTestId } = render(
<>
<Link
to={{
- pathname: '/',
+ pathname: '/explore/',
search: `?${URL_PARAMS.dashboardPageId.name}=${dashboardPageId}`,
state: { saveAction: 'overwrite' },
}}
@@ -324,7 +324,7 @@ describe('ChartPage', () => {
});
render(
<>
- <Link to="/?slice_id=99">Navigate away</Link>
+ <Link to="/explore/?slice_id=99">Navigate away</Link>
<ChartPage />
</>,
{
@@ -382,7 +382,7 @@ describe('ChartPage', () => {
<>
<Link
to={{
- pathname: '/',
+ pathname: '/explore/',
search: `?${URL_PARAMS.sliceId.name}=${formData.slice_id}`,
state: toChartStateHistoryState({
...formData,
@@ -392,7 +392,7 @@ describe('ChartPage', () => {
>
Change the chart
</Link>
- <Link to="/?slice_id=99">Navigate away</Link>
+ <Link to="/explore/?slice_id=99">Navigate away</Link>
<ChartPage />
</>,
{ useRouter: true, useRedux: true, useDnd: true },
@@ -433,14 +433,14 @@ describe('ChartPage', () => {
<>
<Link
to={{
- pathname: '/',
+ pathname: '/explore/',
search: `?${URL_PARAMS.sliceId.name}=99`,
state: toChartStateHistoryState({ ...formData, slice_id: 99 }),
}}
>
Another chart
</Link>
- <Link to="/?slice_id=100">Navigate away</Link>
+ <Link to="/explore/?slice_id=100">Navigate away</Link>
<ChartPage />
</>,
{ useRouter: true, useRedux: true, useDnd: true },
@@ -477,14 +477,14 @@ describe('ChartPage', () => {
<>
<Link
to={{
- pathname: '/',
+ pathname: '/explore/',
search: `?${URL_PARAMS.sliceId.name}=${formData.slice_id}`,
state: toChartStateHistoryState(formData),
}}
>
Change the chart
</Link>
- <Link to="/?slice_id=99">Navigate away</Link>
+ <Link to="/explore/?slice_id=99">Navigate away</Link>
<ChartPage />
</>,
{ useRouter: true, useRedux: true, useDnd: true, store },
@@ -507,6 +507,32 @@ describe('ChartPage', () => {
window.history.back();
await waitFor(() => expect(loads()).toBe(1));
});
+
+ test('does not re-fetch explore data when navigating to a dashboard', async () => {
+ const exploreApiRoute = 'glob:*/api/v1/explore/*';
+ const exploreFormData = getExploreFormData({
+ viz_type: VizType.Table,
+ show_cell_bars: true,
+ });
+ fetchMock.get(exploreApiRoute, {
+ result: { dataset: { id: 1 }, form_data: exploreFormData },
+ });
+ render(
+ <>
+ <Link to="/dashboard/5/">Go to dashboard</Link>
+ <ChartPage />
+ </>,
+ { useRouter: true, useRedux: true, useDnd: true },
+ );
+ await waitFor(() =>
+ expect(fetchMock.callHistory.calls(exploreApiRoute).length).toBe(1),
+ );
+
+ fireEvent.click(screen.getByText('Go to dashboard'));
+
+ await new Promise(resolve => setTimeout(resolve, 0));
+ expect(fetchMock.callHistory.calls(exploreApiRoute).length).toBe(1);
+ });
});
test('does not show error toast when request is aborted on unmount', async () => {
@@ -559,7 +585,7 @@ describe('ChartPage', () => {
render(
<>
- <Link to="/?slice_id=99">Navigate</Link>
+ <Link to="/explore/?slice_id=99">Navigate</Link>
<ChartPage />
</>,
{
diff --git a/superset-frontend/src/pages/Chart/index.tsx b/superset-frontend/src/pages/Chart/index.tsx
index a9f5e98544b..3ed8a11d612 100644
--- a/superset-frontend/src/pages/Chart/index.tsx
+++ b/superset-frontend/src/pages/Chart/index.tsx
@@ -56,6 +56,11 @@ const isValidResult = (rv: JsonObject): boolean =>
const hasDatasetId = (rv: JsonObject): boolean =>
isDefined(rv?.result?.dataset?.id);
+const EXPLORE_ROUTE_PREFIX = '/explore/';
+
+const isExploreRoute = (pathname: string): boolean =>
+ pathname.startsWith(EXPLORE_ROUTE_PREFIX);
+
const fetchExploreData = async (
exploreUrlParams: URLSearchParams,
signal?: AbortSignal,
@@ -312,6 +317,8 @@ export default function ExplorePage() {
// Other REPLACE: ignored (URL sync from updateHistory).
// Entries holding a chart state of the loaded chart are skipped: Explore
// pushed them itself, and ExploreViewContainer restores a popped one in place.
+ // Navigations that leave Explore must not trigger a re-fetch while the page
+ // is unmounting, as the destination's URL params are not chart params.
useEffect(() => {
const unlisten = history.listen((loc: Location, action: Action) => {
const saveAction = (loc.state as Record<string, unknown>)?.saveAction as
@@ -326,6 +333,9 @@ export default function ExplorePage() {
return;
}
}
+ if (!isExploreRoute(loc.pathname)) {
+ return;
+ }
if (action === 'PUSH' || action === 'POP') {
setIsLoaded(false);
loadExploreData(loc, saveAction);