Skip to content
This repository was archived by the owner on Feb 23, 2024. It is now read-only.

Commit 0c2e198

Browse files
committed
use replaceState to avoid changing browser history
1 parent 43b1de2 commit 0c2e198

File tree

4 files changed

+7
-7
lines changed

4 files changed

+7
-7
lines changed

assets/js/blocks/active-filters/utils.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ export const removeArgsFromFilterUrl = (
198198
if ( filteringForPhpTemplate ) {
199199
window.location.href = newUrl;
200200
} else {
201-
window.history.pushState( {}, '', newUrl );
201+
window.history.replaceState( {}, '', newUrl );
202202
}
203203
};
204204

@@ -236,6 +236,6 @@ export const cleanFilterUrl = () => {
236236
if ( filteringForPhpTemplate ) {
237237
window.location.href = newUrl;
238238
} else {
239-
window.history.pushState( {}, '', newUrl );
239+
window.history.replaceState( {}, '', newUrl );
240240
}
241241
};

assets/js/blocks/attribute-filter/block.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,7 @@ const AttributeFilterBlock = ( {
284284
if ( filteringForPhpTemplate ) {
285285
window.location.href = newUrl;
286286
} else {
287-
window.history.pushState( {}, '', newUrl );
287+
window.history.replaceState( {}, '', newUrl );
288288
}
289289
} else {
290290
const newUrl = formatParams( pageUrl, query );
@@ -295,7 +295,7 @@ const AttributeFilterBlock = ( {
295295
if ( filteringForPhpTemplate ) {
296296
window.location.href = newUrl;
297297
} else {
298-
window.history.pushState( {}, '', newUrl );
298+
window.history.replaceState( {}, '', newUrl );
299299
}
300300
}
301301
}

assets/js/blocks/price-filter/block.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ const PriceFilterBlock = ( {
190190
}
191191

192192
// When filtering All Products block, we only update the URL.
193-
window.history.pushState( {}, '', newUrl );
193+
window.history.replaceState( {}, '', newUrl );
194194
}
195195
}
196196

assets/js/blocks/stock-filter/block.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ const StockStatusFilterBlock = ( {
200200
if ( isPhpTemplate ) {
201201
window.location.href = url;
202202
} else {
203-
window.history.pushState( {}, '', url );
203+
window.history.replaceState( {}, '', url );
204204
}
205205
}
206206

@@ -218,7 +218,7 @@ const StockStatusFilterBlock = ( {
218218
if ( isPhpTemplate ) {
219219
window.location.href = newUrl;
220220
} else {
221-
window.history.pushState( {}, '', newUrl );
221+
window.history.replaceState( {}, '', newUrl );
222222
}
223223
};
224224

0 commit comments

Comments
 (0)