File tree Expand file tree Collapse file tree 1 file changed +11
-4
lines changed Expand file tree Collapse file tree 1 file changed +11
-4
lines changed Original file line number Diff line number Diff line change @@ -129,15 +129,22 @@ const HolyLoader = ({
129
129
} ;
130
130
131
131
/**
132
- * Overrides the history. pushState function to stop the progress bar
133
- * when navigating to a new page without a full page reload.
132
+ * Enhances browser history methods ( pushState and replaceState) to ensure that the
133
+ * progress indicator is appropriately halted when navigating through single- page applications
134
134
*/
135
- const overridePushState = ( ) : void => {
135
+ const stopProgressOnHistoryUpdate = ( ) : void => {
136
136
const originalPushState = history . pushState . bind ( history ) ;
137
137
history . pushState = ( ...args ) => {
138
138
stopProgress ( ) ;
139
139
originalPushState ( ...args ) ;
140
140
} ;
141
+
142
+ // This is crucial for Next.js Link components using the 'replace' prop.
143
+ const originalReplaceState = history . replaceState . bind ( history ) ;
144
+ history . replaceState = ( ...args ) => {
145
+ stopProgress ( ) ;
146
+ originalReplaceState ( ...args ) ;
147
+ } ;
141
148
} ;
142
149
143
150
/**
@@ -166,7 +173,7 @@ const HolyLoader = ({
166
173
}
167
174
168
175
startProgress ( ) ;
169
- overridePushState ( ) ;
176
+ stopProgressOnHistoryUpdate ( ) ;
170
177
} catch ( error ) {
171
178
stopProgress ( ) ;
172
179
}
You can’t perform that action at this time.
0 commit comments