[4.x] Fix ->lazy() and ->defer() route macros not working for components without mount()#10106
Merged
calebporzio merged 2 commits intomainfrom Mar 17, 2026
Merged
Conversation
…s without `mount()`
… race condition in CI
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The Scenario
When using
->defer()or->lazy()on a route for a full-page single-file component, the component renders immediately instead of being deferred/lazy loaded. The only workaround is adding the#[Defer]or#[Lazy]attribute directly to the component class, which defeats the purpose of the route macro.The Problem
The
->defer()and->lazy()route macros store their flags in route defaults ($route->defaults['defer']/$route->defaults['lazy']). Laravel merges these defaults into$route->parameters()when the route is matched.In
SupportPageComponents::gatherMountMethodParamsFromRouteParameters(), the parameters are resolved viaImplicitRouteBinding::resolveMountParameters(), which calls$route->resolveMethodDependencies($route->parameters(), ...)against the component'smount()method. Whenmount()exists (even with no parameters),resolveMethodDependenciespasses through all route parameters including defaults, so thedefer/lazykeys reachSupportLazyLoading::mount($params).However, when the component has no
mount()method,resolveMountParameters()returns an empty collection. TheresolveComponentProps()fallback only includes parameters matching public properties. Since there's no$deferor$lazypublic property, the flags are silently dropped and lazy/deferred loading never activates.The Solution
After resolving route parameters in
gatherMountMethodParamsFromRouteParameters(), explicitly mergelazyanddeferroute defaults into the params array (if they're not already present). This ensures the flags always reach component hooks regardless of whether the component has amount()method.Fixes #10093