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

Dynamic filter form population can alter presentation of ChoiceFields elsewhere in the UI #4222

Closed
glennmatthews opened this issue Aug 4, 2023 · 2 comments · Fixed by #4223
Assignees
Labels
emergent Unplanned work that is brought into a sprint after it's started. type: bug Something isn't working as expected

Comments

@glennmatthews
Copy link
Contributor

Environment

  • Nautobot version (Docker tag too if applicable): 1.6.0rc1

Steps to Reproduce

  1. Log in to Nautobot
  2. In one tab, open the /dcim/devices/ list view, open the Filter modal, and switch to the Advanced tab.
  3. In another browser tab, open the "run" view for a Job that defines a ChoiceVar. Observe that the ChoiceVar is correctly represented as a single-value Select2 widget in the UI.
  4. In the first tab, in the Filter modal, select "Rack Face" in the first column, then "exact" in the second column.
  5. Refresh the second tab.

Expected Behavior

No change on page refresh

Observed Behavior

The ChoiceVar now gets incorrectly rendered as a multi-value Select2 widget.

This is due to incorrect code in get_filterset_parameter_form_field() which is inadvertently modifying the forms.ChoiceField class directly instead of only changing a single instance of that class.

@glennmatthews glennmatthews added the type: bug Something isn't working as expected label Aug 4, 2023
@glennmatthews glennmatthews self-assigned this Aug 4, 2023
@glennmatthews
Copy link
Contributor Author

Thank you to the many folks who helped identify, reproduce, and troubleshoot this issue, including @Dav-C, @jtdub, @joewesch. @matt852.

@glennmatthews
Copy link
Contributor Author

Workaround to temporarily "unbreak" the Job form after this issue is encountered:

  • Navigate again to /dcim/devices, open the Filter modal, and switch to the Advanced tab.
  • Select "Has a primary IP" and then select "exact"
  • Refresh the job tab.

This is because there's a second code path that also incorrectly modifies forms.ChoiceField when making a different kind of selection from the advanced filter form; we're just lucky in that this code path modifies it to somewhat closer to the original, desired behavior of the form field. Both code paths will be fixed in #4223.

@bryanculver bryanculver added the emergent Unplanned work that is brought into a sprint after it's started. label Aug 7, 2023
glennmatthews added a commit that referenced this issue Aug 7, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 6, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
emergent Unplanned work that is brought into a sprint after it's started. 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.

2 participants