From 0ca7d50615cd2e239fe3770463873e0dd03ab49f Mon Sep 17 00:00:00 2001 From: vicrodh <103399283+vicrodh@users.noreply.github.com> Date: Sun, 11 Jan 2026 01:50:08 -0600 Subject: [PATCH] fix(lyrics): resolve scrolling in ExpandedPlayer full screen view - Add min-height: 0 and height: 100% to .right-section for proper flex constraint cascade - Add overflow: hidden to .lyrics-container for mask effect - Add max-height: 100% and overflow-y: auto to .lyrics-lines - Fix reset effect to track content changes vs array reference - Remove debug console.logs --- src/lib/components/ExpandedPlayer.svelte | 7 +++-- src/lib/components/lyrics/LyricsLines.svelte | 28 +++----------------- 2 files changed, 8 insertions(+), 27 deletions(-) diff --git a/src/lib/components/ExpandedPlayer.svelte b/src/lib/components/ExpandedPlayer.svelte index 068c1e52f..f8891ecc0 100644 --- a/src/lib/components/ExpandedPlayer.svelte +++ b/src/lib/components/ExpandedPlayer.svelte @@ -93,9 +93,7 @@ // Ensure lyrics updates run when ExpandedPlayer is open with synced lyrics $effect(() => { - console.log('[ExpandedPlayer] Effect check:', { isOpen, isPlaying, lyricsSynced, lyricsActiveIndex, hasLyrics: lyricsLines.length > 0 }); if (isOpen && isPlaying && lyricsSynced) { - console.log('[ExpandedPlayer] Starting lyrics updates'); startActiveLineUpdates(); } }); @@ -665,17 +663,20 @@ .right-section { flex: 1; min-width: 0; + min-height: 0; /* Critical for nested flex to respect max-height */ display: flex; flex-direction: column; justify-content: center; overflow: hidden; padding-right: 40px; + height: 100%; /* Explicit height for proper constraint cascade */ } .lyrics-container { flex: 1; min-height: 0; /* Critical for flex child to allow shrinking */ max-height: calc(100vh - 160px); + overflow: hidden; /* Clip content for mask effect */ mask-image: linear-gradient( to bottom, transparent 0%, @@ -699,6 +700,8 @@ --bg-tertiary: rgba(255, 255, 255, 0.08); padding: 0; height: 100%; + max-height: 100%; /* Constrain to parent height */ + overflow-y: auto; /* Ensure scrolling works */ } .lyrics-state { diff --git a/src/lib/components/lyrics/LyricsLines.svelte b/src/lib/components/lyrics/LyricsLines.svelte index f7b477242..d4b07c49a 100644 --- a/src/lib/components/lyrics/LyricsLines.svelte +++ b/src/lib/components/lyrics/LyricsLines.svelte @@ -48,18 +48,11 @@ // Scroll active line into view (centered) // instant: true for catch-up sync, false for normal progression async function scrollActiveIntoView(index: number, instant: boolean = false) { - console.log('[LyricsLines] scrollActiveIntoView called', { index, instant, hasContainer: !!container }); - - if (!container || index < 0) { - console.log('[LyricsLines] Early return - no container or invalid index'); - return; - } + if (!container || index < 0) return; await tick(); const target = container.querySelector(`[data-line-index="${index}"]`); - console.log('[LyricsLines] Found target element:', !!target); - if (!target) return; const containerRect = container.getBoundingClientRect(); @@ -68,8 +61,6 @@ const containerCenter = containerRect.top + containerRect.height / 2; const scrollOffset = targetCenter - containerCenter; - console.log('[LyricsLines] Scrolling by', scrollOffset, { targetCenter, containerCenter }); - container.scrollBy({ top: scrollOffset, behavior: instant ? 'instant' : 'smooth' @@ -78,26 +69,14 @@ // React to activeIndex changes - scroll to keep active line visible $effect(() => { - console.log('[LyricsLines] Effect running', { scrollToActive, activeIndex, isSynced, lastScrolledIndex }); - - // Only scroll if we should and have a valid index - if (!scrollToActive || activeIndex < 0 || !isSynced) { - console.log('[LyricsLines] Skipping scroll - conditions not met'); - return; - } - - // Skip if we already scrolled to this index - if (activeIndex === lastScrolledIndex) { - console.log('[LyricsLines] Skipping scroll - same index'); - return; - } + if (!scrollToActive || activeIndex < 0 || !isSynced) return; + if (activeIndex === lastScrolledIndex) return; // Determine scroll behavior const isLargeJump = lastScrolledIndex >= 0 && Math.abs(activeIndex - lastScrolledIndex) > 2; const isInitialSync = lastScrolledIndex === -1 && activeIndex > 0; const useInstant = isLargeJump || isInitialSync; - console.log('[LyricsLines] Will scroll to', activeIndex, { isLargeJump, isInitialSync, useInstant }); lastScrolledIndex = activeIndex; scrollActiveIntoView(activeIndex, useInstant); }); @@ -107,7 +86,6 @@ $effect(() => { 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; }