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

Fix errors when filter does not exist #979

Merged

Conversation

KaulSe
Copy link
Contributor

@KaulSe KaulSe commented Dec 8, 2022

All Submissions:

  • Have you followed the guidelines in our Contributing document?
  • Have you checked to ensure there aren't other open Pull Requests for the same update/change?

Changes to Core Features:

  • Have you added an explanation of what your changes do and why you'd like us to include them?
  • Have you written new tests for your core changes, as applicable?
  • Have you successfully ran tests with your changes locally?

The application throws an error when supplying an invalid filter key in the URL. The appropriate action would be to ignore the invalid filter key.

Steps to reproduce

  1. You have a table
  2. You supply an invalid filter. For example, it is possible to accomplish that by changing the filter key in the URL. An example: http://localhost:8000/dashboard?table[filters][invalid-filter]=test.
  3. You now see an error.

Errors it fixes

  1. Rappasoft\LaravelLivewireTables\DataTableComponent::Rappasoft\LaravelLivewireTables\Traits\Helpers\{closure}(): Argument #1 ($filter) must be of type Rappasoft\LaravelLivewireTables\Views\Filter, null given, called in /..../src/Illuminate/Collections/Traits/EnumeratesValues.php on line 780
  2. Error: Call to a member function isEmpty() on null: /..../src/Traits/ComponentUtilities.php:97

I expect that the application does not accept invalid filters (filters not defined in filters()) and doesn't error on such input.

This PR fixes this behavior.

@KaulSe
Copy link
Contributor Author

KaulSe commented Dec 8, 2022

Ready for review :).

rappasoft added a commit that referenced this pull request Dec 21, 2022
@rappasoft rappasoft added the Awaiting Next Release Currently merged into development awaiting a release to master label Dec 21, 2022
@rappasoft rappasoft mentioned this pull request Dec 22, 2022
@rappasoft rappasoft merged commit c2bdfba into rappasoft:master Dec 22, 2022
@KaulSe KaulSe deleted the fix-errors-when-filter-does-not-exist branch December 23, 2022 13:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Awaiting Next Release Currently merged into development awaiting a release to master
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants