@dev.smartpricing/message-composer-layer 1.0.21 → 1.0.22
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,18 +1,35 @@
|
|
|
1
1
|
import { ref, unref, type ComputedRef } from 'vue'
|
|
2
|
+
import { useEventListener } from '@vueuse/core'
|
|
2
3
|
import { type RouteLocationRaw } from 'vue-router'
|
|
3
4
|
|
|
4
5
|
export function useExitConfirmation(shouldBlockNavigation: ComputedRef<boolean>) {
|
|
5
6
|
const isForcingNavigation = ref(false)
|
|
6
7
|
const isNavigatingTo = ref<RouteLocationRaw | null>(null)
|
|
8
|
+
const isPopstateNavigation = ref(false)
|
|
9
|
+
const isSelfTriggeredBack = ref(false)
|
|
7
10
|
|
|
8
11
|
const { confirm } = useConfirm()
|
|
9
12
|
const { t } = useI18n()
|
|
13
|
+
const { goBackOrFallback } = useGoBack()
|
|
14
|
+
|
|
15
|
+
// Detect browser back/forward navigation
|
|
16
|
+
useEventListener(window, 'popstate', () => {
|
|
17
|
+
if (isSelfTriggeredBack.value) {
|
|
18
|
+
isSelfTriggeredBack.value = false
|
|
19
|
+
return
|
|
20
|
+
}
|
|
21
|
+
isPopstateNavigation.value = true
|
|
22
|
+
})
|
|
10
23
|
|
|
11
24
|
// Setup route guard
|
|
12
25
|
onBeforeRouteLeave((_to, _from, next) => {
|
|
13
26
|
const _isForcedNavigation = unref(isForcingNavigation)
|
|
14
27
|
isForcingNavigation.value = false
|
|
15
28
|
|
|
29
|
+
// Capture and reset popstate flag immediately
|
|
30
|
+
const wasPopstate = isPopstateNavigation.value
|
|
31
|
+
isPopstateNavigation.value = false
|
|
32
|
+
|
|
16
33
|
if (shouldBlockNavigation.value && !_isForcedNavigation) {
|
|
17
34
|
isNavigatingTo.value = _to
|
|
18
35
|
next(false)
|
|
@@ -26,7 +43,13 @@ export function useExitConfirmation(shouldBlockNavigation: ComputedRef<boolean>)
|
|
|
26
43
|
const target = isNavigatingTo.value
|
|
27
44
|
if (target) {
|
|
28
45
|
isForcingNavigation.value = true
|
|
29
|
-
|
|
46
|
+
if (wasPopstate) {
|
|
47
|
+
isSelfTriggeredBack.value = true
|
|
48
|
+
goBackOrFallback(target)
|
|
49
|
+
}
|
|
50
|
+
else {
|
|
51
|
+
navigateTo(target)
|
|
52
|
+
}
|
|
30
53
|
isNavigatingTo.value = null
|
|
31
54
|
}
|
|
32
55
|
},
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dev.smartpricing/message-composer-layer",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.22",
|
|
4
4
|
"private": false,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./nuxt.config.ts",
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
"vue-router": "^5.0.6",
|
|
40
40
|
"vue3-emoji-picker": "^1.1.8",
|
|
41
41
|
"zod": "^4.4.1",
|
|
42
|
-
"@dev.smartpricing/message-composer-utils": "3.1.
|
|
42
|
+
"@dev.smartpricing/message-composer-utils": "3.1.22"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
45
|
"@nuxt/eslint": "^1.15.2",
|