diff --git a/static/js/app.js b/static/js/app.js index 04becc9..b2bc46d 100644 --- a/static/js/app.js +++ b/static/js/app.js @@ -61,9 +61,11 @@ document.addEventListener("alpine:init", () => { */ scrollToBottom(el) { if (el) { - // Use requestAnimationFrame for smoother scrolling after DOM update + // Use double RAF to ensure DOM has fully updated and reflowed requestAnimationFrame(() => { - el.scrollTop = el.scrollHeight; + requestAnimationFrame(() => { + el.scrollTop = el.scrollHeight; + }); }); } }, @@ -329,13 +331,17 @@ document.addEventListener("alpine:init", () => { `/apps/${this.appId}/deployments/${this.deploymentId}/logs`, ); const data = await res.json(); - this.logs = data.logs || "No logs available"; + const newLogs = data.logs || "No logs available"; + const logsChanged = newLogs !== this.logs; + this.logs = newLogs; this.status = data.status; - // Scroll to bottom after update - this.$nextTick(() => { - Alpine.store("utils").scrollToBottom(this.$refs.logsWrapper); - }); + // Scroll to bottom only when content changes + if (logsChanged) { + this.$nextTick(() => { + Alpine.store("utils").scrollToBottom(this.$refs.logsWrapper); + }); + } // Stop polling if deployment is done if (!Alpine.store("utils").isDeploying(data.status)) {