-
Notifications
You must be signed in to change notification settings - Fork 263
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
Q search box in Secrets fails #4572
Comments
Whomever at core looks into this, please put your analysis here, even if not coding a fix. I have a similar issue in GC, and have to presume either this will be fixed in core (in which case I will just wait) or potentially need to implement same fix in GC, which I can potentially do right away even if this issue in core is not fixed. |
Looks related to #3574's changes. |
I put in a JS breakpoint, the one that worked said |
Fortunately in this case the traceback tells us the exact line where the error is occurring (Line 615 in let default_filter_form_query = $("#default-filter form").serialize().split("&").filter(params => params.split("=")[1].length) At the time of initial rendering this value is undefined (the let default_filter_form_query = $("#default-filter form").serialize().split("&").filter(params => params.split("=")[1]?.length || 0 ) You can introspect this in the console by calling > $("#default-filter form").serialize()
<- 'provider=constant-value' Lastly, you might be wondering "but I entered this in the Search box, not the dynamic filter form!" They're all processed as a single form input underneath the hood using a formset (a form of forms). So even the search form is included in the dynamic filter form processing. |
That was helpful, thanks!!! I now know what the question mark operator is in JS and I figured it just required some defensive programming (I was looking for a So I also get that the name is not defined on the filterform defaults (which aligns with my original issue), I still don't understand why that matters? Put another way, adding a |
I think it only matters for the two lines that look identical in the JS but one is "dynamic" and one is "default". It's really just this: class SecretFilterForm(NautobotFilterForm):
model = Secret
q = forms.CharField(required=False, label="Search")
provider = forms.MultipleChoiceField(
choices=provider_choices_with_blank, widget=StaticSelect2Multiple(), required=False
)
tags = TagFilterField(model) Since only For reference, here is the q = SearchFilter(
filter_predicates={
"name": "icontains",
},
) |
Environment
Steps to Reproduce
Expected Behavior
A filtered list view
Observed Behavior
JS crashes with:
The text was updated successfully, but these errors were encountered: