inertiajs / inertia-laravel

The Laravel adapter for Inertia.js.
https://inertiajs.com
MIT License
1.99k stars 222 forks source link

[1.x] Fix resolving shared dot props #636

Closed lepikhinb closed 1 month ago

lepikhinb commented 1 month ago

Based on https://github.com/inertiajs/inertia-laravel/pull/634

I think https://github.com/inertiajs/inertia-laravel/pull/620 introduced a breaking change when sharing props through the middleware, as described in https://github.com/inertiajs/inertia-laravel/issues/633

This PR includes extra tests to ensure shared props can be included and excluded from partial responses.

VicGUTT commented 1 month ago

Same comment as in https://github.com/inertiajs/inertia-laravel/pull/634#issuecomment-2143360780.

Might be worth investigation if the PR https://github.com/inertiajs/inertia-laravel/pull/631 also solve this issue?

lepikhinb commented 1 month ago

@VicGUTT it doesn't. However, I think #631 can be simplified a bit.

VicGUTT commented 1 month ago

Alright, too bad. Thanks for confirming.

Sure, in what way? That PR simply reverted back the method "resolvePropertyInstances" to what it previously was

lepikhinb commented 1 month ago

@reinink I rewrote the entire partial request resolving logic. It seems that the only way to support nested partial props without introducing any breaking changes is to check each prop independently to determine whether it should be included or excluded from the partial response.

Additionally, we need to resolve dot-notated props last to ensure they are merged after any parent closures are resolved.