Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(nuxt): don't show transition on initial page load #24935

Merged
merged 4 commits into from
Jan 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 3 additions & 1 deletion packages/nuxt/src/app/components/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import type { Component, RendererNode } from 'vue'
import { isString, isPromise, isArray, isObject } from '@vue/shared'
import destr from 'destr'
import type { RouteLocationNormalized } from '#vue-router'
// @ts-expect-error virtual file
import { START_LOCATION } from '#build/pages'

/**
* Internal utility
Expand All @@ -29,7 +31,7 @@ function generateRouteKey (route: RouteLocationNormalized) {
* return true if the route has been changed with a page change during navigation
*/
export function isChangingPage (to: RouteLocationNormalized, from: RouteLocationNormalized) {
if (to === from) { return false }
if (to === from || from === START_LOCATION) { return false }

// If route keys are different then it will result in a rerender
if (generateRouteKey(to) !== generateRouteKey(from)) { return true }
Expand Down
7 changes: 5 additions & 2 deletions packages/nuxt/src/pages/module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,10 @@ export default defineNuxtModule({
addPlugin(resolve(distDir, 'app/plugins/router'))
addTemplate({
filename: 'pages.mjs',
getContents: () => 'export { useRoute } from \'#app\''
getContents: () => [
'export { useRoute } from \'#app/composables/router\'',
'export const START_LOCATION = Symbol(\'router:start-location\')'
].join('\n')
})
addComponent({
name: 'NuxtPage',
Expand Down Expand Up @@ -371,7 +374,7 @@ export default defineNuxtModule({
// Add vue-router import for `<NuxtLayout>` integration
addTemplate({
filename: 'pages.mjs',
getContents: () => 'export { useRoute } from \'vue-router\''
getContents: () => 'export { START_LOCATION, useRoute } from \'vue-router\''
})

// Optimize vue-router to ensure we share the same injection symbol
Expand Down