diff --git a/airflow-core/src/airflow/ui/src/pages/XCom/XComModal.tsx b/airflow-core/src/airflow/ui/src/pages/XCom/XComModal.tsx index b16b8161f6640..f7f9494786ae5 100644 --- a/airflow-core/src/airflow/ui/src/pages/XCom/XComModal.tsx +++ b/airflow-core/src/airflow/ui/src/pages/XCom/XComModal.tsx @@ -58,6 +58,7 @@ const XComModal = ({ dagId, isOpen, mapIndex, mode, onClose, runId, taskId, xcom dagRunId: runId, deserialize: true, mapIndex, + stringify: false, taskId, xcomKey: xcomKey ?? "", }, @@ -67,12 +68,12 @@ const XComModal = ({ dagId, isOpen, mapIndex, mode, onClose, runId, taskId, xcom // Populate form when editing useEffect(() => { - if (isEditMode && data?.value !== undefined) { + if (isOpen && isEditMode && data) { const val = data.value; setValue(typeof val === "string" ? val : JSON.stringify(val, undefined, 2)); } - }, [data, isEditMode]); + }, [data, isEditMode, isOpen]); // Reset form when modal closes useEffect(() => { @@ -113,13 +114,25 @@ const XComModal = ({ dagId, isOpen, mapIndex, mode, onClose, runId, taskId, xcom type: "error", }); }, - onSuccess: async () => { + onSuccess: async (response) => { + queryClient.setQueryData( + [ + useXcomServiceGetXcomEntryKey, + { + dagId, + dagRunId: runId, + deserialize: true, + mapIndex, + stringify: false, + taskId, + xcomKey, + }, + ], + response, + ); await queryClient.invalidateQueries({ queryKey: [useXcomServiceGetXcomEntriesKey], }); - await queryClient.invalidateQueries({ - queryKey: [useXcomServiceGetXcomEntryKey], - }); onClose(); toaster.create({ description: translate("browse:xcom.edit.success"),