diff --git a/src/helpers/browser-back-button.js b/src/helpers/browser-back-button.js
new file mode 100644
index 000000000..aea9605d5
--- /dev/null
+++ b/src/helpers/browser-back-button.js
@@ -0,0 +1,9 @@
+export const disabledBackButton = () => {
+ window.location.hash = 'no-back-button'
+
+ window.location.hash = 'Again-No-back-button'
+
+ window.onhashchange = function () {
+ window.location.hash = 'no-back-button'
+ }
+}
diff --git a/src/helpers/index.js b/src/helpers/index.js
index c08c1bcf3..c34acb2d9 100644
--- a/src/helpers/index.js
+++ b/src/helpers/index.js
@@ -37,6 +37,7 @@ import FILTERS_RULES from './real-time-filters-rules'
import { openGraphQlPlayground } from './open-graphql-playground.js'
import { eventsPlaygroundOpener } from './events-playground-opener'
import { setRedirectRoute, getRedirectRoute } from './login-redirect-manager'
+import { disabledBackButton } from './browser-back-button'
export {
InviteSession,
@@ -81,5 +82,6 @@ export {
openGraphQlPlayground,
eventsPlaygroundOpener,
setRedirectRoute,
- getRedirectRoute
+ getRedirectRoute,
+ disabledBackButton
}
diff --git a/src/templates/dialog-unsaved-block/index.vue b/src/templates/dialog-unsaved-block/index.vue
index c13ddd9bd..81fc3e9af 100644
--- a/src/templates/dialog-unsaved-block/index.vue
+++ b/src/templates/dialog-unsaved-block/index.vue
@@ -1,8 +1,9 @@
diff --git a/src/tests/helpers/browser-back-button.test.js b/src/tests/helpers/browser-back-button.test.js
new file mode 100644
index 000000000..e52757241
--- /dev/null
+++ b/src/tests/helpers/browser-back-button.test.js
@@ -0,0 +1,28 @@
+import { afterAll, describe, expect, it, vi } from 'vitest'
+import { disabledBackButton } from '@/helpers/browser-back-button'
+
+vi.stubGlobal('window', {
+ location: {
+ hash: ''
+ },
+ onhashchange: null
+})
+
+describe('disabledBackButton', () => {
+ afterAll(() => {
+ vi.unstubAllGlobals()
+ })
+ it('should update window.location.hash to "Again-No-back-button"', () => {
+ disabledBackButton()
+ expect(window.location.hash).toBe('Again-No-back-button')
+ })
+
+ it('should reset window.location.hash to "no-back-button" on hash change', () => {
+ disabledBackButton()
+
+ window.location.hash = 'some-other-hash'
+ window.onhashchange()
+
+ expect(window.location.hash).toBe('no-back-button')
+ })
+})