From e404048c5bedc2badacd816c893a6a9680a0ecc8 Mon Sep 17 00:00:00 2001 From: vicrodh <103399283+vicrodh@users.noreply.github.com> Date: Fri, 23 Jan 2026 20:51:09 -0600 Subject: [PATCH] fix(artist): bio truncation reactivity, adjust margins - Observe parent container for resize (not clamped element) - Double RAF ensures CSS applies before measurement - top-tracks-section: margin-top 32px - artist-header: margin-bottom 22px --- .../components/views/ArtistDetailView.svelte | 32 ++++++++++++------- 1 file changed, 21 insertions(+), 11 deletions(-) diff --git a/src/lib/components/views/ArtistDetailView.svelte b/src/lib/components/views/ArtistDetailView.svelte index d34f2fbad..600c41482 100644 --- a/src/lib/components/views/ArtistDetailView.svelte +++ b/src/lib/components/views/ArtistDetailView.svelte @@ -577,6 +577,7 @@ // Smart 3-line truncation with resize detection let bioTextEl = $state(null); + let bioContainerEl = $state(null); let isBioTruncated = $state(false); function checkBioTruncation() { @@ -586,19 +587,26 @@ } $effect(() => { - if (!bioTextEl || !bioText) return; + if (!bioTextEl || !bioText || !bioContainerEl) return; - // Initial check - checkBioTruncation(); + // Initial check after a frame to ensure layout is complete + requestAnimationFrame(() => { + checkBioTruncation(); + }); - // Observe resize to recalculate when container width changes + // Observe the PARENT container (not the clamped element) for width changes const observer = new ResizeObserver(() => { if (!bioExpanded) { - checkBioTruncation(); + // Double RAF to ensure CSS has applied after resize + requestAnimationFrame(() => { + requestAnimationFrame(() => { + checkBioTruncation(); + }); + }); } }); - observer.observe(bioTextEl); + observer.observe(bioContainerEl); return () => observer.disconnect(); }); @@ -606,9 +614,11 @@ // Recheck truncation after collapsing (wait for DOM update) $effect(() => { if (bioExpanded === false && bioTextEl) { - // Use requestAnimationFrame to wait for CSS to apply + // Use double RAF to wait for CSS to fully apply requestAnimationFrame(() => { - checkBioTruncation(); + requestAnimationFrame(() => { + checkBioTruncation(); + }); }); } }); @@ -877,7 +887,7 @@ {#if bioText} -
+
{@html bioText}
@@ -1556,7 +1566,7 @@ .artist-header { display: flex; gap: 32px; - margin-bottom: 32px; + margin-bottom: 22px; } .artist-image-column { @@ -2272,7 +2282,7 @@ /* Top Tracks */ .top-tracks-section { - padding-top: 10px; + margin-top: 32px; margin-bottom: 32px; }