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

Deep merge props from partial reloads #1877

Merged
merged 1 commit into from
May 20, 2024

Conversation

lepikhinb
Copy link
Contributor

@lepikhinb lepikhinb commented May 18, 2024

Deep merge props on partial visits instead of simple concatenation, to preserve deeply nested props that are not present in the partial response. Array values will be replaced with new values.

Introduces required changes for inertiajs/inertia-laravel#620

Initial response:

{
  "user": {
    "id": 1,
    "name": "New user",
    "email": "boris@example.com"
  }
}

Partial request:

router.put(
  '/profile',
  {
    name: 'Boris Lepikhin'
  },
  {
    only: ['user.name'],
  }
)

Page props (auth.user.id preserved):

{
  "user": {
    "id": 1,
    "name": "New user",
    "email": "boris@example.com"
  }
}

@lepikhinb lepikhinb marked this pull request as ready for review May 18, 2024 23:19
@taylorotwell taylorotwell merged commit 7179279 into inertiajs:master May 20, 2024
4 checks passed
@reinink reinink changed the title [1.x] Deep merge properties Deep merge props from partial reloads May 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants