- Notifications
You must be signed in to change notification settings - Fork62
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Fix error component by adding name check#1356
Merged
Merged
Conversation
This file contains 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 freeto 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
With the recent changes to error component to support nesting#1308, occasionally there can be an issue if
$errors->first()
is called in a test, as it throws anUndefined variable $errors
error. This recently caused a breaking change for someone.The problem
The issue is actually an underlying Laravel issue where for some reason if a view is manually rendered in a test, it has no idea that the
$errors
variable should exist and throws an error.https://laracasts.com/discuss/channels/testing/undefined-variable-errors-when-testing-a-viewBy itself, this shouldn't cause issues for us, but with the recent change to the errors component, this error is now being throws in a users app.
The reason why it wasn't being thrown before, is because we only had the below code.
You can see here that if no
$name
prop is provided, it will never call the$errors->first()
.But we recently just added the below, which is causing
$errors->first()
to always be called, hence is throwing the error.The solution
The easy win solution is to just update the conditional to also check for a name. So that's what has been done in this PR.
Fixes#1330