fix(n8n Form Node): Duplicate popup in manual mode (#11925)

Co-authored-by: कारतोफ्फेलस्क्रिप्ट™ <aditya@netroy.in>
This commit is contained in:
Michael Kret
2024-11-27 15:19:06 +02:00
committed by GitHub
parent 9669380097
commit 2c34bf4ea6
3 changed files with 24 additions and 28 deletions

View File

@@ -82,25 +82,28 @@ export const executionFilterToQueryFilter = (
return queryFilter;
};
export const openPopUpWindow = (
url: string,
options?: { width?: number; height?: number; alwaysInNewTab?: boolean },
) => {
const windowWidth = window.innerWidth;
const smallScreen = windowWidth <= 800;
if (options?.alwaysInNewTab || smallScreen) {
return window.open(url, '_blank');
} else {
const height = options?.width || 700;
const width = options?.height || window.innerHeight - 50;
let formPopupWindow: Window | null = null;
export const openFormPopupWindow = (url: string) => {
if (!formPopupWindow || formPopupWindow.closed) {
const height = 700;
const width = window.innerHeight - 50;
const left = (window.innerWidth - height) / 2;
const top = 50;
const features = `width=${height},height=${width},left=${left},top=${top},resizable=yes,scrollbars=yes`;
const windowName = `form-waiting-since-${Date.now()}`;
return window.open(url, windowName, features);
formPopupWindow = window.open(url, windowName, features);
} else {
formPopupWindow.location = url;
formPopupWindow.focus();
}
};
export const closeFormPopupWindow = () => {
formPopupWindow?.close();
formPopupWindow = null;
};
export function displayForm({
nodes,
runData,
@@ -131,7 +134,7 @@ export function displayForm({
if (node.name === destinationNode || !node.disabled) {
let testUrl = '';
if (node.type === FORM_TRIGGER_NODE_TYPE) testUrl = getTestUrl(node);
if (testUrl && source !== 'RunData.ManualChatMessage') openPopUpWindow(testUrl);
if (testUrl && source !== 'RunData.ManualChatMessage') openFormPopupWindow(testUrl);
}
}
}