Open n0099 opened 2 months ago
Stackblitz link for the reproduction: Stackblitz
Looks like a complex app. Would you be able to provide a minimal reproduction? 🙏
Would you be able to provide a reproduction? 🙏
scroll to the bottom of page and click the button with text
下一页
In fact this step should be repeated two times, the first time to click that button won't trigger this.
I fixed this by changing the inline-function
style v-on
event handler on that button which wrapping an async function with plain method
or inline
handler:
-@clickNextPage="async () => await fetchNextPage()"
+@clickNextPage="fetchNextPage()"
+@clickNextPage="fetchNextPage"
I fixed this by changing...
It's still reproducible :(
You should not call use useRoute in a click handler. Call it in your setup function and use the route object in the click handler
useRoute in a click handler
I'm not. https://github.com/n0099/open-tbm/blob/e7c516a2ac5bad2e726074fe9155c9b93c940df0/fe/src/components/post/badge/Common.vue#L49 It's in a <script setup>
of SFC.
(Just mentioned in case. I'm still waiting for a minimal reproduction to check in more detail.)
~It seems that prevent re-render <NuxtPage>
when changing route can fix this even with @clickNextPage="async () => await fetchNextPage()"
~
- <NuxtPage />
+ <NuxtPage :pageKey="route => route.path.split('/')[1]" />
No it's still reproducible. About minimal reprod: I tried to make one: https://codesandbox.io/p/devbox/new-water-vxj48t but it won't reproduce.
Report from the field: Nuxt 3.13.1 with Nitro 2.9.7
Nuxt Ui UCommandPalette with @update:model-value="onSelect"
function onSelect (option) { router.push({ path: option.id }) }
Calling useRoute
within middleware may lead to misleading results. Instead, use the (to, from) arguments passed to the middleware to access the new and old routes.
@nightlyworker Is it possible for you to extract a minimal reprod of your case? I've already tried this but failed.
I will try tomorrow with stackblitz nuxt UI template TIL. I'm not familiar with it.
Here is the gist:
<template>
<UCommandPalette
ref="commandPaletteRef"
:groups="groups"
icon=""
:ui="ui"
:autoselect="false"
@update:model-value="onSelect"
>
</UCommandPalette>
</template>
<script setup>
const router = useRouter()
...
function onSelect (option) {
console.log('onSelect')
if (option.id) {
state.isSearchOpen = false
console.log(state)
router.push({ path: option.id })
}
</script>
This component is ClientOnly Clicking on the result will call onSelect which makes router.push will raise the warning.
For reference: https://ui.nuxt.com/components/command-palette
Environment
Reproduction
access https://localhost/tbm/posts/fid/228500/cursor/vNcpHQI,bLKIZg,lMJmGCM,mKqzZg,W3eEFSM,kuKoZg in browser and open devtools scroll to the bottom of page and click the button with text
下一页
you can see manyconsole.warn()
with callstack at https://github.com/n0099/open-tbm/blob/e7c516a2ac5bad2e726074fe9155c9b93c940df0/fe/src/components/post/badge/Common.vue#L49Describe the bug
https://github.com/nuxt/nuxt/blob/d5cf409ddca078266bd71ca011b9bc6ed6e58e05/packages/nuxt/src/app/composables/router.ts#L21-L22 https://github.com/nuxt/nuxt/blob/d5cf409ddca078266bd71ca011b9bc6ed6e58e05/packages/nuxt/src/app/composables/router.ts#L81-L84 https://github.com/nuxt/nuxt/blob/d5cf409ddca078266bd71ca011b9bc6ed6e58e05/packages/nuxt/src/pages/runtime/plugins/router.ts#L193 https://github.com/nuxt/nuxt/blob/d5cf409ddca078266bd71ca011b9bc6ed6e58e05/packages/nuxt/src/app/plugins/router.ts#L245
Additional context
No response
Logs
No response