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

A valid "None" value in a search field will be removed on subsequent searches #1524

Closed
bminnix opened this issue Mar 21, 2022 · 1 comment · Fixed by #1820
Closed

A valid "None" value in a search field will be removed on subsequent searches #1524

bminnix opened this issue Mar 21, 2022 · 1 comment · Fixed by #1820
Assignees
Labels
type: bug Something isn't working as expected

Comments

@bminnix
Copy link

bminnix commented Mar 21, 2022

Environment

  • Python version: 3.7.12
  • Nautobot version: v1.2.9

Steps to Reproduce

  1. Using the search box in Devices; select a None value from a dropdown (Tenant, Rack Group, Rack all have this value in the demo)
  2. Also select other values in other fields, values do not matter
  3. Perform search

Expected Behavior

All explicitly selected values should remain for a subsequent search.

Observed Behavior

Only values != None were retained, all None values are stripped from previously populated form.

NOTE:
Per discussion with Jathan, this is happening because of the value None is being interpreted as the null value when passed through the JS form rendering. This is expected behavior for the JS rendering but unexpected behavior for the application.

A solution that was tested is that any field that may contain the default value None, would have a companion field instead of containing the value. Examples are "Has console ports" and "Has console server ports" so that a boolean value could be used in place of the default null value.

@jathanism
Copy link
Contributor

jathanism commented Mar 21, 2022

This is an interesting side effect from the way that query parameters that come through in the URL get passed into the UI filter form. So rack_id=null for example gets rendered in the form as rack_id=None which the filter interprets as None the Python object and not "None" the string.

This is in fact working as originally designed by having a null_option="None" argument on such fields, for example:

    rack_id = DynamicModelMultipleChoiceField(
        queryset=Rack.objects.all(),
        required=False,
        label="Rack",
        null_option="None",
        query_params={
            "site": "$site",
            "group_id": "$rack_group_id",
        },
    )

The problem as we determined is that this behavior is surprising and not easily fixable without either eliminating the null option, or fixing the reversible nature of the UI filter query generated by the filter form. The query filter does actually work, it's just that such field values do not get repopulated in the filter form in the UI, causing the confusion.

@jathanism jathanism added type: bug Something isn't working as expected group: ui-ux labels Mar 21, 2022
@timizuoebideri1 timizuoebideri1 self-assigned this May 25, 2022
bryanculver added a commit that referenced this issue Jun 2, 2022
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 1, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
type: bug Something isn't working as expected
Projects
No open projects
Archived in project
Development

Successfully merging a pull request may close this issue.

3 participants