Skip to content
This repository was archived by the owner on Apr 6, 2023. It is now read-only.
/frameworkPublic archive

fix(nuxt3)!: sync route object to currently resolved page - #4092

Merged
pi0 merged 4 commits into
mainfrom
fix/suspended-route
Apr 5, 2022
Merged

fix(nuxt3)!: sync route object to currently resolved page#4092
pi0 merged 4 commits into
mainfrom
fix/suspended-route

Conversation

@danielroe

Copy link
Copy Markdown
Member

🔗 Linked issue

resolvesnuxt/nuxt#13645, resolves https://github.com/nuxt/framework/discussions/2459

❓ Type of change

  • 📖 Documentation (updates to the documentation or readme)
  • 🐞 Bug fix (a non-breaking change that fixes an issue)
  • 👌 Enhancement (improving an existing functionality like performance)
  • ✨ New feature (a non-breaking change that adds functionality)
  • ⚠️ Breaking change (fix or feature that would cause existing functionality to change)

📚 Description

This PR does two things:

  1. correctly resolves the route for use within plugins (previously useRoute() did not return the correct route until the plugin lifecycle had fully run)
  2. creates a 'suspended' route that mirrors the behaviour of the page component - so it does not resolve to the new route until the page component resolves

I would especially welcome testing on this given the nature of the change.

📝 Checklist

  • I have linked an issue or discussion.
  • I have updated the documentation accordingly.

@danielroedanielroe added bug Something isn't working nuxt3 pages 🍰 p2-nice-to-have Priority 2: nothing is broken but it's worth addressing labels Apr 5, 2022
@danielroe
danielroe requested a review from pi0April 5, 2022 13:14
@danielroedanielroe self-assigned this Apr 5, 2022
@netlify

netlifyBot commented Apr 5, 2022

Copy link
Copy Markdown

Deploy Preview for nuxt3-docs ready!

NameLink
🔨 Latest commit297c87e
🔍 Latest deploy loghttps://app.netlify.com/sites/nuxt3-docs/deploys/624c53f0cfa6290008475187
😎 Deploy Previewhttps://deploy-preview-4092--nuxt3-docs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

Comment threadpackages/nuxt3/src/pages/runtime/router.ts Outdated
Comment threadpackages/nuxt3/src/pages/runtime/router.ts Outdated
@atinux

Copy link
Copy Markdown
Member

Nice work @danielroe

It would be nice to test indeed and check if it works when using a nested page too 😊

pi0
pi0 approved these changes Apr 5, 2022

@pi0pi0 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me. Please ping when did additional tests otherwise we can try with edge to test behavior.

@danielroe

Copy link
Copy Markdown
MemberAuthor

Tested ✅

Note: At the moment, a nested page's async setup doesn't block the loading of the parent, which means it doesn't block the updating of the route object. That may be a separate issue to track, but it doesn't seem to be an issue with this PR.

@pi0
pi0 merged commit 7a70644 into mainApr 5, 2022
@pi0
pi0 deleted the fix/suspended-route branch April 5, 2022 15:36
@misaon

misaon commented Apr 6, 2022

Copy link
Copy Markdown
Contributor

@danielroe I fighting with following case:

app.vue

<template>
<div>
<NuxtLayout>
<NuxtPage/>
</NuxtLayout>
</div>
</template>

pages/index.vue

<template>
<div>
<NuxtLink to="/hi.html">
Go to Hi page
</NuxtLink>
</div>
</template>

pages/[slug].html.vue

<template>
<div>
<h1>Hi</h1>
</div>
</template>
<script lang="ts" setup>const route =useRoute()console.log(route.params)</script>

console

{}

How can i get slug param value now after your change?

@misaon

Copy link
Copy Markdown
Contributor

Im going back to 3.0.0-27486179.cb74ab6

Sign up for freeto subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

3.xbugSomething isn't workingnuxt3🍰 p2-nice-to-havePriority 2: nothing is broken but it's worth addressingpages

Projects

None yet

Development

Successfully merging this pull request may close these issues.

suspend route object until route suspense resolves

4 participants

@danielroe@atinux@misaon@pi0