From 37fb929366fe330d216e62e724223335040e8f85 Mon Sep 17 00:00:00 2001 From: Steffen Deusch Date: Fri, 27 Mar 2026 19:52:53 +0100 Subject: [PATCH] Recompute scroll container if it is no longer available Closes #4169. --- assets/js/phoenix_live_view/hooks.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/assets/js/phoenix_live_view/hooks.js b/assets/js/phoenix_live_view/hooks.js index 0eb0adb688..28d1986824 100644 --- a/assets/js/phoenix_live_view/hooks.js +++ b/assets/js/phoenix_live_view/hooks.js @@ -264,6 +264,15 @@ Hooks.InfiniteScroll = { } }, + updated() { + // Check if the scroll container still exists + // https://github.com/phoenixframework/phoenix_live_view/issues/4169. + if (!this.scrollContainer.isConnected) { + this.destroyed(); + this.mounted(); + } + }, + destroyed() { if (this.scrollContainer) { this.scrollContainer.removeEventListener("scroll", this.onScroll);