diff --git a/src/components/task.vue b/src/components/task.vue index 507ae99ab..bc1a30f90 100644 --- a/src/components/task.vue +++ b/src/components/task.vue @@ -455,6 +455,7 @@ export default { const elementDestinationUrl = elementDestination.value; if (elementDestinationUrl) { + sessionStorage.setItem('sessionUrlActionBlocker', document.referrer); return elementDestinationUrl; } @@ -797,6 +798,30 @@ export default { requestIdNode.setAttribute('content', this.requestId); } }, + /** + * Checks for the presence of a URL action blocker in sessionStorage and handles it. + * + * This method retrieves the 'sessionUrlActionBlocker' value from sessionStorage, + * and if present, removes it and emits a 'closed' event with the task id and + * the source of the redirection. It returns false if the blocker was handled, + * and true otherwise. + * + * @returns {boolean} Returns false if the 'sessionUrlActionBlocker' was found and handled, true otherwise. + */ + hasUrlActionBloker() { + // Retrieve the 'sessionUrlActionBlocker' value from sessionStorage + const redirectedFrom = sessionStorage.getItem("sessionUrlActionBlocker"); + + if (redirectedFrom) { + // Remove 'sessionUrlActionBlocker' from sessionStorage after retrieving its value + sessionStorage.removeItem("sessionUrlActionBlocker"); + + // Emit a 'closed' event with the task id and the source of the redirection + this.$emit("closed", this.task?.id, redirectedFrom); + return true; + } + return false; + }, }, mounted() { @@ -807,7 +832,9 @@ export default { this.nodeId = this.initialNodeId; this.requestData = this.value; this.loopContext = this.initialLoopContext; - this.loadTask(); + if (!this.hasUrlActionBloker()) { + this.loadTask(); + } }, destroyed() { this.unsubscribeSocketListeners();