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

[1.1.0] Partial reload sets all $page props to undefined #1883

Closed
fragkp opened this issue May 30, 2024 · 6 comments · Fixed by #1895
Closed

[1.1.0] Partial reload sets all $page props to undefined #1883

fragkp opened this issue May 30, 2024 · 6 comments · Fixed by #1895
Assignees
Labels
investigate The issue needs further investigating

Comments

@fragkp
Copy link

fragkp commented May 30, 2024

Version:

  • @inertiajs/vue3 version: 1.1.0

Describe the problem:

When updating from 1.0.6 to 1.1.0 unexpectedly the behavior of $page props has changed. It will set all page props to undefined when a partial reload with only is called.

Steps to reproduce:

<template>
    <h1>{{ $page.props.user.name }}</h1>
</template>

<script setup>
    onMounted(() => {
        router.reload({
            only: ['some-prop'],
        });
    });
</script>

The user page prop is now undefined! It affects not only props in templates but also when usePage() is used.

reinink added a commit that referenced this issue May 30, 2024
reinink added a commit that referenced this issue May 30, 2024
@reinink
Copy link
Member

reinink commented May 30, 2024

Hey! I just tried to reproduce this issue and wasn't able to. Both the page props passed to the page component, as well as the $page.prop property and usePage() values were all still set after doing a partial reload.

You can see my test here:

https://github.com/inertiajs/inertia/blob/issue-1883/playgrounds/vue3/resources/js/Pages/Users.vue

We did recently make some changes to how partial reloads work (see #1876 and #1877), so it's entirely possible that there is some situation we didn't account for, but I am unable to reproduce it.

Are you able to provide a minimal reproduction of this issue using this Vue 3 playground?

@fragkp
Copy link
Author

fragkp commented May 30, 2024

Will create a playground later today 😃

Thanks for your quick response!

@reinink
Copy link
Member

reinink commented May 30, 2024

Awesome, thanks!

@fragkp
Copy link
Author

fragkp commented May 30, 2024

Unfortunately, I can't reproduce it on your playground (maybe, because we rely heavily on nested layouts with parameters?), but I found our mistake:

On our reload call

router.reload({ only: ['some-prop'] });

some-prop is not passed to the view:

inertia('Page', array_merge([], $active ? [
    'some-prop' => 'value',
] : [
    // missing
]))

On 1.0.6, when missing some-prop will be null. On 1.0.0 it completely wipes the page props for some reason.

I'm unsure if it is a bug in the new version if inertia or some weird hack on our codebase.

@driesvints driesvints added the investigate The issue needs further investigating label May 30, 2024
@reinink
Copy link
Member

reinink commented Jun 13, 2024

Hey I think we've fixed this now in v1.2.0 👍

@fragkp
Copy link
Author

fragkp commented Jun 17, 2024

@reinink Testet it. Works as before. Thanks 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
investigate The issue needs further investigating
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants