From dcdddf384c32f5d975d236a1fcdc7fe7d015831a Mon Sep 17 00:00:00 2001 From: vicrodh <103399283+vicrodh@users.noreply.github.com> Date: Mon, 9 Feb 2026 23:15:56 -0600 Subject: [PATCH] fix: remove inner scroll from Search tabs, use parent scroll container Search tabs (albums, tracks, artists) had their own overflow-y scroll containers, causing double scrollbars and preventing the global back-to-top button and sticky search bar from working. - Remove height, min-height, overflow from .virtual-scroll-container - Remove scrollbar pseudo-element CSS for virtual containers - Feed virtual scroll calculations from parent .search-view scroll - Remove per-container onscroll handlers (unused) - ResizeObservers now only track width for grid column calculations - Container height comes from parent scroll viewport --- src/lib/components/views/SearchView.svelte | 82 ++++++++-------------- 1 file changed, 31 insertions(+), 51 deletions(-) diff --git a/src/lib/components/views/SearchView.svelte b/src/lib/components/views/SearchView.svelte index 5e4421826..ac35f8032 100644 --- a/src/lib/components/views/SearchView.svelte +++ b/src/lib/components/views/SearchView.svelte @@ -71,6 +71,24 @@ const target = event.target as HTMLDivElement; isScrolled = target.scrollTop > 60; saveScrollPosition('search', target.scrollTop); + + // Feed virtual scroll calculations from the main scroll container + const viewportH = target.clientHeight; + if (albumsVirtualEl) { + const offset = albumsVirtualEl.offsetTop; + albumsScrollTop = Math.max(0, target.scrollTop - offset); + albumsContainerHeight = viewportH; + } + if (tracksVirtualEl) { + const offset = tracksVirtualEl.offsetTop; + tracksScrollTop = Math.max(0, target.scrollTop - offset); + tracksContainerHeight = viewportH; + } + if (artistsVirtualEl) { + const offset = artistsVirtualEl.offsetTop; + artistsScrollTop = Math.max(0, target.scrollTop - offset); + artistsContainerHeight = viewportH; + } } function handleResize() { @@ -891,10 +909,6 @@ return albumVirtualItems.slice(s, e + 1); }); - function handleAlbumsScroll(e: Event) { - albumsScrollTop = (e.target as HTMLDivElement).scrollTop; - } - // --- Tracks tab virtualization --- const TRACK_ROW_HEIGHT = 72; const TRACK_ROW_GAP = 4; @@ -902,7 +916,6 @@ let tracksVirtualEl: HTMLDivElement | null = $state(null); let tracksScrollTop = $state(0); let tracksContainerHeight = $state(0); - let tracksResizeObs: ResizeObserver | null = null; interface TrackVirtualItem { type: 'track'; @@ -948,10 +961,6 @@ return trackVirtualItems.slice(s, e + 1); }); - function handleTracksScroll(e: Event) { - tracksScrollTop = (e.target as HTMLDivElement).scrollTop; - } - // --- Artists tab virtualization --- const ARTIST_CARD_WIDTH = 160; const ARTIST_CARD_HEIGHT = 220; @@ -1021,38 +1030,31 @@ return artistVirtualItems.slice(s, e + 1); }); - function handleArtistsScroll(e: Event) { - artistsScrollTop = (e.target as HTMLDivElement).scrollTop; - } - // --- ResizeObserver setup/teardown --- + // Height comes from the parent scroll container (.search-view), not from virtual elements. + // ResizeObservers only track width for album/artist grid column calculations. function setupResizeObservers() { + // Set initial container heights from the scroll container + if (scrollContainer) { + const viewportH = scrollContainer.clientHeight; + albumsContainerHeight = viewportH; + tracksContainerHeight = viewportH; + artistsContainerHeight = viewportH; + } + if (albumsVirtualEl && !albumsResizeObs) { - albumsContainerHeight = albumsVirtualEl.clientHeight; albumsContainerWidth = albumsVirtualEl.clientWidth; albumsResizeObs = new ResizeObserver((entries) => { for (const entry of entries) { - albumsContainerHeight = entry.contentRect.height; albumsContainerWidth = entry.contentRect.width; } }); albumsResizeObs.observe(albumsVirtualEl); } - if (tracksVirtualEl && !tracksResizeObs) { - tracksContainerHeight = tracksVirtualEl.clientHeight; - tracksResizeObs = new ResizeObserver((entries) => { - for (const entry of entries) { - tracksContainerHeight = entry.contentRect.height; - } - }); - tracksResizeObs.observe(tracksVirtualEl); - } if (artistsVirtualEl && !artistsResizeObs) { - artistsContainerHeight = artistsVirtualEl.clientHeight; artistsContainerWidth = artistsVirtualEl.clientWidth; artistsResizeObs = new ResizeObserver((entries) => { for (const entry of entries) { - artistsContainerHeight = entry.contentRect.height; artistsContainerWidth = entry.contentRect.width; } }); @@ -1069,7 +1071,6 @@ onDestroy(() => { albumsResizeObs?.disconnect(); - tracksResizeObs?.disconnect(); artistsResizeObs?.disconnect(); }); @@ -1755,7 +1756,7 @@ {#if albumResults.items.length === 0}