This is an automated email from the ASF dual-hosted git repository.

bbovenzi pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/airflow.git


The following commit(s) were added to refs/heads/main by this push:
     new deac14e5a5e Only redirect on the dag detail page (#54920)
deac14e5a5e is described below

commit deac14e5a5e35a5ec0f50ca869be4c07bc85eaab
Author: Brent Bovenzi <[email protected]>
AuthorDate: Mon Aug 25 11:50:35 2025 -0500

    Only redirect on the dag detail page (#54920)
---
 airflow-core/src/airflow/ui/src/queries/useTrigger.ts | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/airflow-core/src/airflow/ui/src/queries/useTrigger.ts 
b/airflow-core/src/airflow/ui/src/queries/useTrigger.ts
index 0f5a99ab4a8..933f59ad32e 100644
--- a/airflow-core/src/airflow/ui/src/queries/useTrigger.ts
+++ b/airflow-core/src/airflow/ui/src/queries/useTrigger.ts
@@ -19,7 +19,7 @@
 import { useQueryClient } from "@tanstack/react-query";
 import { useState } from "react";
 import { useTranslation } from "react-i18next";
-import { useNavigate } from "react-router-dom";
+import { useNavigate, useParams } from "react-router-dom";
 
 import {
   UseDagRunServiceGetDagRunsKeyFn,
@@ -37,6 +37,7 @@ export const useTrigger = ({ dagId, onSuccessConfirm }: { 
dagId: string; onSucce
   const [error, setError] = useState<unknown>(undefined);
   const { t: translate } = useTranslation("components");
   const navigate = useNavigate();
+  const { dagId: selectedDagId } = useParams();
 
   const onSuccess = async (dagRun: TriggerDagRunResponse) => {
     const queryKeys = [
@@ -55,7 +56,10 @@ export const useTrigger = ({ dagId, onSuccessConfirm }: { 
dagId: string; onSucce
     });
     onSuccessConfirm();
 
-    navigate(`/dags/${dagRun.dag_id}/runs/${dagRun.dag_run_id}`);
+    // Only redirect if we're already on the dag page
+    if (selectedDagId === dagRun.dag_id) {
+      navigate(`/dags/${dagRun.dag_id}/runs/${dagRun.dag_run_id}`);
+    }
   };
 
   const onError = (_error: unknown) => {

Reply via email to