Files
supabase/apps/docs/lib/historyUtils.ts
Devanshu Sharma 0674343912 Fix(docs): prevent SecurityError from rapid history.replaceState call… (#38672)
* Fix(docs): prevent SecurityError from rapid history.replaceState calls during fast scrolling

* url now chases the scroll

* fixing merge conflicts

* refactor: minor changes to safeHistoryReplaceState

---------

Co-authored-by: Charis <26616127+charislam@users.noreply.github.com>
2025-09-18 21:00:10 +00:00

14 lines
345 B
TypeScript

import { debounce } from 'lodash-es'
export const safeHistoryReplaceState = debounce((url: string) => {
if (typeof window === 'undefined') return
if (url === window.location.href) return
try {
window.history.replaceState(null, '', url)
} catch (error) {
console.warn('Failed to call history.replaceState:', error)
}
}, 120)