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.x] Fix shared dot props #634

Closed
wants to merge 1 commit into from

Conversation

RobertBoes
Copy link
Contributor

I think #620 introduced a breaking change when sharing props through the middleware, as described in #633

A use-case would be the following:

class HandleInertiaRequests extends Middleware
{
	public function share(Request $request): array
	{
		return array_merge(parent::share($request), [
			'user.verified' => true,
		]);
	}
}

Then render the page using:

Inertia::render('User/Show', [
	'user' => [
		'name' => 'John',
	],
]);

This would result in just props: { user: { name: 'John' }} being sent to the frontend instead of props: { user: { name: 'John', verified: true }}, with this PR the latter would happen.

I attempted to fix the issue by merging the props instead of overwriting them. However, I'm not actually sure why this feature worked before, since it seems like props were always overwritten.

@RobertBoes RobertBoes changed the base branch from 2.x to 1.x May 31, 2024 14:36
@VicGUTT
Copy link

VicGUTT commented Jun 1, 2024

Hey @RobertBoes, without looking to deep into it and although that was not the intended fix of my PR, I was wondering if my PR #631 doesn't also resolve the issue described here?

The point of my PR was to simply revert back the order of which property instances and arrayable properties were resolved prior to #620.

@driesvints driesvints changed the title Fix shared dot props [1.x] Fix shared dot props Jun 3, 2024
@reinink reinink closed this in #641 Jun 13, 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.

2 participants