From fd178b864308c84332ebaf220e23d2c4f80bfc95 Mon Sep 17 00:00:00 2001 From: vicrodh <103399283+vicrodh@users.noreply.github.com> Date: Sun, 11 Jan 2026 01:35:12 -0600 Subject: [PATCH] fix(lyrics): resolve scrolling issue in ExpandedPlayer - Fix reset effect to track actual content changes instead of array reference, preventing constant lastScrolledIndex resets in Svelte 5 - Add min-height: 0 to lyrics-container for proper flex height calculation --- src/lib/components/ExpandedPlayer.svelte | 2 +- src/lib/components/lyrics/LyricsLines.svelte | 11 ++++++++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/lib/components/ExpandedPlayer.svelte b/src/lib/components/ExpandedPlayer.svelte index 003be6c37..068c1e52f 100644 --- a/src/lib/components/ExpandedPlayer.svelte +++ b/src/lib/components/ExpandedPlayer.svelte @@ -674,7 +674,7 @@ .lyrics-container { flex: 1; - overflow: hidden; + min-height: 0; /* Critical for flex child to allow shrinking */ max-height: calc(100vh - 160px); mask-image: linear-gradient( to bottom, diff --git a/src/lib/components/lyrics/LyricsLines.svelte b/src/lib/components/lyrics/LyricsLines.svelte index 484350780..f7b477242 100644 --- a/src/lib/components/lyrics/LyricsLines.svelte +++ b/src/lib/components/lyrics/LyricsLines.svelte @@ -31,6 +31,7 @@ let container: HTMLDivElement | null = null; let lastScrolledIndex = -1; + let lastLyricsKey = ''; // Calculate opacity based on distance from active line function getLineOpacity(index: number, active: number): number { @@ -102,10 +103,14 @@ }); // Reset scroll tracking when lyrics change (new track) + // Use first line text as key to detect actual content change, not just array reference $effect(() => { - // This effect only cares about lines array identity changing - void lines; - lastScrolledIndex = -1; + const newKey = lines.length > 0 ? `${lines.length}-${lines[0].text}` : ''; + if (newKey !== lastLyricsKey) { + console.log('[LyricsLines] Lyrics content changed, resetting scroll tracking'); + lastLyricsKey = newKey; + lastScrolledIndex = -1; + } });