From de9fae63b841b082fe84a1948b5f8b1f2f38e1a9 Mon Sep 17 00:00:00 2001 From: yyh Date: Wed, 10 Dec 2025 13:17:30 +0800 Subject: [PATCH] fixes #29390: align async window open behavior with inline logic --- web/hooks/use-async-window-open.ts | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/web/hooks/use-async-window-open.ts b/web/hooks/use-async-window-open.ts index 33ccb062bd..c767097ca3 100644 --- a/web/hooks/use-async-window-open.ts +++ b/web/hooks/use-async-window-open.ts @@ -17,28 +17,32 @@ export const useAsyncWindowOpen = () => { const { successMessage, errorMessage = 'Failed to open page', - windowFeatures = 'noopener,noreferrer', + windowFeatures = 'noopener', onError, onSuccess, } = options const newWindow = window.open('', '_blank', windowFeatures) + if (!newWindow) { + const error = new Error('Failed to open new window') + onError?.(error) + Toast.notify({ + type: 'error', + message: errorMessage, + }) + return + } + try { const url = await fetchUrl() if (url) { - if (newWindow) { - try { - newWindow.opener = null - } - catch { /* noop */ } - newWindow.location.href = url - } - else { - // Fallback: navigate current tab if we couldn't get a window reference - window.location.href = url + try { + newWindow.opener = null } + catch { /* noop */ } + newWindow.location.href = url onSuccess?.(url) if (successMessage) {