@@ -28,7 +28,8 @@ import {
2828 createSignal ,
2929 createMemo ,
3030 onMount ,
31- onCleanup
31+ onCleanup ,
32+ useContext
3233} from "solid-js"
3334import { format } from "date-fns"
3435import ExploreVersionsNavbar from "@/components/ExploreVersionsNavbar"
@@ -66,14 +67,33 @@ const ModsInfiniteScrollQueryWrapper = () => {
6667 const params = useParams ( )
6768 const platform = ( ) => params . platform as FEUnifiedPlatform
6869
70+ // Hoisted project query to pass addonType to InfiniteScrollVersionsQueryWrapper
71+ const project = rspc . createQuery ( ( ) => ( {
72+ queryKey : [
73+ "modplatforms.unifiedGetProject" ,
74+ platform ( ) === "curseforge"
75+ ? {
76+ type : "curseforge" ,
77+ value : parseInt ( params . id , 10 )
78+ }
79+ : {
80+ type : "modrinth" ,
81+ value : params . id
82+ }
83+ ]
84+ } ) )
85+
6986 return (
7087 < InfiniteScrollVersionsQueryWrapper
7188 modId = { params . id }
7289 modplatform = { platform ( ) }
90+ addonType = { project . data ?. type }
7391 >
74- < ContentWrapper zeroPadding >
75- < AddonExplore />
76- </ ContentWrapper >
92+ < AddonContext . Provider value = { project } >
93+ < ContentWrapper zeroPadding >
94+ < AddonExplore />
95+ </ ContentWrapper >
96+ </ AddonContext . Provider >
7797 </ InfiniteScrollVersionsQueryWrapper >
7898 )
7999}
@@ -116,20 +136,8 @@ const AddonExplore = () => {
116136 enabled : selectedInstanceId ( ) !== undefined
117137 } ) )
118138
119- const project = rspc . createQuery ( ( ) => ( {
120- queryKey : [
121- "modplatforms.unifiedGetProject" ,
122- platform ( ) === "curseforge"
123- ? {
124- type : "curseforge" ,
125- value : parseInt ( params . id , 10 )
126- }
127- : {
128- type : "modrinth" ,
129- value : params . id
130- }
131- ]
132- } ) )
139+ // Use the hoisted project query from context
140+ const project = useContext ( AddonContext ) !
133141
134142 const isFetching = ( ) => project . isLoading
135143
@@ -236,11 +244,26 @@ const AddonExplore = () => {
236244
237245 // Measure sticky header height for versions table positioning
238246 if ( refStickyTabs ) {
247+ let rafId : number | null = null
248+
239249 const resizeObserver = new ResizeObserver ( ( ) => {
240- setStickyHeaderHeight ( refStickyTabs . getBoundingClientRect ( ) . height )
250+ // Debounce with requestAnimationFrame to avoid layout thrashing
251+ // when Select dropdowns open (prevents page shift)
252+ if ( rafId !== null ) {
253+ cancelAnimationFrame ( rafId )
254+ }
255+ rafId = requestAnimationFrame ( ( ) => {
256+ setStickyHeaderHeight ( refStickyTabs . getBoundingClientRect ( ) . height )
257+ rafId = null
258+ } )
241259 } )
242260 resizeObserver . observe ( refStickyTabs )
243- onCleanup ( ( ) => resizeObserver . disconnect ( ) )
261+ onCleanup ( ( ) => {
262+ if ( rafId !== null ) {
263+ cancelAnimationFrame ( rafId )
264+ }
265+ resizeObserver . disconnect ( )
266+ } )
244267 }
245268 } )
246269
0 commit comments