@@ -44,34 +44,6 @@ export const FeedList = ({
4444 return networkParam || initialNetwork
4545 }
4646
47- // Force initial sync with URL
48- useEffect ( ( ) => {
49- // Get the latest network from URL
50- const latestNetworkFromURL = getNetworkFromURL ( )
51- if ( latestNetworkFromURL !== currentNetwork ) {
52- setCurrentNetwork ( latestNetworkFromURL )
53- }
54-
55- // Force a redraw after a short delay
56- if ( typeof window !== "undefined" ) {
57- // execute after the DOM is fully loaded
58- window . addEventListener ( "load" , ( ) => {
59- const networkFromURL = getNetworkFromURL ( )
60- setCurrentNetwork ( networkFromURL )
61-
62- // Force a repaint of aria-selected attributes
63- document . querySelectorAll ( ".network-button" ) . forEach ( ( button ) => {
64- const buttonId = button . getAttribute ( "id" )
65- if ( buttonId === networkFromURL ) {
66- button . setAttribute ( "aria-selected" , "true" )
67- } else {
68- button . setAttribute ( "aria-selected" , "false" )
69- }
70- } )
71- } )
72- }
73- } , [ ] )
74-
7547 // Sync with URL when it changes externally (browser back/forward)
7648 useEffect ( ( ) => {
7749 if ( ! isStreams && typeof window !== "undefined" ) {
@@ -106,7 +78,9 @@ export const FeedList = ({
10678
10779 const params = new URLSearchParams ( window . location . search )
10880 params . set ( "network" , network )
109- const newUrl = window . location . pathname + "?" + params . toString ( )
81+ // Preserve the hash fragment if it exists
82+ const hashFragment = window . location . hash
83+ const newUrl = window . location . pathname + "?" + params . toString ( ) + hashFragment
11084 window . history . replaceState ( { path : newUrl } , "" , newUrl )
11185 setCurrentNetwork ( network )
11286 }
@@ -146,6 +120,24 @@ export const FeedList = ({
146120 const wrapperRef = useRef ( null )
147121 const [ showOnlySVR , setShowOnlySVR ] = useState ( false )
148122
123+ // Scroll restoration handler - re-scroll to hash target after content loads
124+ useEffect ( ( ) => {
125+ if ( typeof window === "undefined" || ! window . location . hash ) return
126+
127+ // Check if chainMetadata has loaded (content is ready)
128+ if ( ! chainMetadata . loading && chainMetadata . processedData ) {
129+ // Wait for any DOM updates to finish
130+ setTimeout ( ( ) => {
131+ const targetId = window . location . hash . substring ( 1 )
132+ const targetElement = document . getElementById ( targetId )
133+ if ( targetElement ) {
134+ // Use scrollIntoView with behavior: auto to ensure proper positioning
135+ targetElement . scrollIntoView ( { behavior : "auto" } )
136+ }
137+ } , 100 )
138+ }
139+ } , [ chainMetadata . loading , chainMetadata . processedData ] )
140+
149141 // Network selection handler
150142 function handleNetworkSelect ( chain : Chain ) {
151143 if ( ! isStreams ) {
@@ -174,7 +166,8 @@ export const FeedList = ({
174166 if ( searchValue === "" ) {
175167 const searchParams = new URLSearchParams ( window . location . search )
176168 searchParams . delete ( "search" )
177- const newUrl = window . location . pathname + "?" + searchParams . toString ( )
169+ const hashFragment = window . location . hash
170+ const newUrl = window . location . pathname + "?" + searchParams . toString ( ) + hashFragment
178171 window . history . replaceState ( { path : newUrl } , "" , newUrl )
179172 const inputElement = document . getElementById ( "search" ) as HTMLInputElement
180173 if ( inputElement ) {
0 commit comments