Skip to content

Commit d06c0a9

Browse files
author
Barthélémy Ledoux
authored
fix: onUnmounted warning in topnav (#18988)
* refactor: order of items in topnav for comments * fix: warning of the topnav
1 parent 866264b commit d06c0a9

File tree

1 file changed

+30
-23
lines changed
  • packages/frontend-shared/src/gql-components/topnav

1 file changed

+30
-23
lines changed

packages/frontend-shared/src/gql-components/topnav/TopNav.vue

+30-23
Original file line numberDiff line numberDiff line change
@@ -211,9 +211,7 @@ import { allBrowsersIcons } from '@packages/frontend-shared/src/assets/browserLo
211211
import { gql, useMutation } from '@urql/vue'
212212
import { TopNavFragment, TopNav_LaunchOpenProjectDocument, TopNav_SetBrowserDocument } from '../../generated/graphql'
213213
import { useI18n } from '@cy/i18n'
214-
import { computed, ref } from 'vue'
215-
// eslint-disable-next-line no-duplicate-imports
216-
import type { Ref } from 'vue'
214+
import { computed, ref, Ref } from 'vue'
217215
const { t } = useI18n()
218216
import { onClickOutside, onKeyStroke, useTimeAgo } from '@vueuse/core'
219217
import DocsMenuContent from './DocsMenuContent.vue'
@@ -284,34 +282,43 @@ const props = defineProps<{
284282
showBrowsers?: boolean
285283
}>()
286284
287-
const docsMenuVariant: Ref<'main' | 'orchestration' | 'ci'> = ref('main')
288-
289-
const promptsEl: Ref<HTMLElement | null> = ref(null)
290-
291-
// reset docs menu if click or keyboard navigation happens outside
292-
// so it doesn't reopen on the one of the prompts
293-
294-
const versions = computed(() => {
285+
const versions = (() => {
295286
if (!props.gql.versions) {
296-
return null
287+
return ref(null)
297288
}
298289
299-
return {
300-
current: {
301-
released: useTimeAgo(new Date(props.gql.versions.current.released)).value,
302-
version: props.gql.versions.current.version,
303-
},
304-
latest: {
305-
released: useTimeAgo(new Date(props.gql.versions.latest.released)).value,
306-
version: props.gql.versions.latest.version,
307-
},
308-
}
309-
})
290+
const currentReleased = useTimeAgo(new Date(props.gql.versions.current.released))
291+
const latestReleased = useTimeAgo(new Date(props.gql.versions.latest.released))
292+
293+
return computed(() => {
294+
if (!props.gql.versions) {
295+
return null
296+
}
297+
298+
return {
299+
current: {
300+
released: currentReleased.value,
301+
version: props.gql.versions.current.version,
302+
},
303+
latest: {
304+
released: latestReleased.value,
305+
version: props.gql.versions.latest.version,
306+
},
307+
}
308+
})
309+
})()
310310
311311
const runningOldVersion = computed(() => {
312312
return props.gql.versions ? props.gql.versions.current.released < props.gql.versions.latest.released : false
313313
})
314314
315+
const docsMenuVariant: Ref<'main' | 'orchestration' | 'ci'> = ref('main')
316+
317+
const promptsEl: Ref<HTMLElement | null> = ref(null)
318+
319+
// reset docs menu if click or keyboard navigation happens outside
320+
// so it doesn't reopen on the one of the prompts
321+
315322
onClickOutside(promptsEl, () => {
316323
setTimeout(() => {
317324
// reset the content of the menu when

0 commit comments

Comments
 (0)