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

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

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

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

Conversation

@danielroe
Copy link
Member

🔗 Linked issue

resolves nuxt/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.

@danielroe danielroe 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 pi0 April 5, 2022 13:14
@danielroe danielroe self-assigned this Apr 5, 2022
@netlify
Copy link

netlify bot commented Apr 5, 2022

Deploy Preview for nuxt3-docs ready!

Name Link
🔨 Latest commit 297c87e
🔍 Latest deploy log https://app.netlify.com/sites/nuxt3-docs/deploys/624c53f0cfa6290008475187
😎 Deploy Preview https://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.

@atinux
Copy link
Member

atinux commented Apr 5, 2022

Nice work @danielroe

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

Copy link
Member

@pi0 pi0 left a comment

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
Member Author

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 main Apr 5, 2022
@pi0 pi0 deleted the fix/suspended-route branch April 5, 2022 15:36
@misaon
Copy link
Contributor

misaon commented Apr 6, 2022

@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
Contributor

misaon commented Apr 6, 2022

Im going back to 3.0.0-27486179.cb74ab6

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

Labels

3.x bug Something isn't working nuxt3 🍰 p2-nice-to-have Priority 2: nothing is broken but it's worth addressing pages

Projects

None yet

Development

Successfully merging this pull request may close these issues.

suspend route object until route suspense resolves

4 participants