-
-
Notifications
You must be signed in to change notification settings - Fork 340
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
[Bug]: Invalid Query Param Values on MultiSelectFilter cause error #2033
Comments
Will look at this tomorrow, thanks for reporting I will likely remove the empty and use a forelse instead of foreach, which will cater for not displaying empty values |
So a few more tweaks for this one that I first thought to make it a bit cleaner/more logical. Instead of that logic being in the blade, I'm going to move it into the method that retrieves it, ensuring that it's validated before being retrieved for display. At the same time, I'm going to fix the errant (superfluous) separator after the last item in the array. |
The final change with this fix, is just a minor adjustment to the blade, to utilise the method
Where "class=''" is being used, and splitting up the layout/color classes This bit is just prep work for when we add in the appropriate methods to manipulate which classes are applied to these elements down the line |
#2035 - Is the PR that should address this. It should be merged into development shortly, alongside an additional fix for the NumberFilter. |
This is now in the development branch, and will be in the next release (later today) @leesherwood - please do feel free to test it while it's in the "dev-development" branch |
This should now be released. |
Can confirm latest release resolves the issue. Only been working with the library for a couple of hours so not familiar with it enough to anticipate and test for side effects but if I do find any I will report back. |
What happened?
TypeError is thrown if you pass an invalid value in the query parameter of a MultiSelectFilter
How to reproduce the bug
Create a table with any MultiSelectFilter, such as:
Enable the filter selecting only ONE value, then modify the URL query string to have an invalid filter value:
Hit enter and the error will appear
Package Version
3.5.0
PHP Version
8.1.x
Laravel Version
11.10.0
Alpine Version
No response
Theme
Tailwind 3.x
Notes
When the filter values are passed through this function: https://github.com/rappasoft/laravel-livewire-tables/blob/master/src/Views/Filters/MultiSelectFilter.php#L37 , it returns an empty array as it correctly discards our edited invalid value.
This empty array is then output here: https://github.com/rappasoft/laravel-livewire-tables/blob/master/resources/views/components/tools/filter-pills.blade.php#L42
The first condition is false, so it drops into the
else
which is then running{{ [] }}
or<?php echo e([]); ?>
The easiest fix is to remove the
&& !empty($filterPillValue)
on the first condition. It will show the filter applied with no values, but better than an error and not entirely an unexpected result (I think this would be fine).A "better" fix might be to disable the filter if there's no valid value post-sanitisation.
Error Message
No response
The text was updated successfully, but these errors were encountered: