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
Shared props issues #29
Comments
Maybe it's also worth storing the |
I also getting problems with shared props today. For example, |
there might be a side-effect, but it may help to derive the baseRoute - or actually its URL - from the referer header. public function share(Request $request)
{
return array_merge(parent::share($request),
$request->isRouteOrReferer('admin.*') ? [
// your data to pass in for this specific route-pattern
] : [],
);
} the macro: use Illuminate\Http\Request;
Request::macro('isRouteOrReferer', function (String $routePattern) {
if ($this->routeIs($routePattern)) {
return true;
}
if ($refererUrl = $this->header('referer')) {
$routeName = rescue(
fn () => app('router')->getRoutes()->match(app('request')->create($refererUrl, 'GET'))->getName(),
report: false
);
return Str::is($routePattern, $routeName);
}
return false;
}); |
I'm also having the same issue. My component error props are intercepted by the base route not the rendered modal. If I remove the baseRoute it works just fine. |
While using your great package (thanks!), I noticed that the approach sometimes does not generate the desired output. For example, my
HandleInertiaRequests
middleware returns the breadcrumbs for every request but when I render a modal the breadcrumbs of the background page are obviously not correct because the route of the modal is used. In general, I think as soon as the shared props are different for modal and background page it causes issues. Should the middleware hence run twice? Not sure how Laravel will behave then so it's more like an architectural question.The text was updated successfully, but these errors were encountered: