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

#2311: New ComboBox widget for form fields [BOB] #3302

Open
wants to merge 23 commits into
base: main
Choose a base branch
from

Conversation

dave-kennedy-ecs
Copy link
Contributor

@dave-kennedy-ecs dave-kennedy-ecs commented Jan 6, 2025

Ticket

Resolves #2311

Changes

  • New ComboboxWidget added, which can be used in place of Select widget throughout app
  • DomainRequest RequestingEntity Form now using ComboboxWidget for Federal Agency and State/Territory
  • DomainRequest OrganizationContact Form now using ComboboxWidget for Federal Agency and State/Territory
  • Domain Suborganization Form, now using Combobox for Suborganization
  • Domain OrganizationNameAddress Form now using ComboboxWidget for Federal Agency and State/Territory
  • Portfolio/Organization OrganizationNameAddress Form now using ComboboxWidget for State/Territory
  • Updated dynamic form for RequestingEntity to account for ComboBoxes instead of Selects, as the javascript keys off of certain DOM elements to drive the dynamic aspects of the page
  • Edited the uswds combobox code in order for error classes to be handled properly

Context for reviewers

Setup

These options on the different forms are not always visible and depends on waffle flag settings. To test Domain Request Organization form (federal agency and state/territory combo boxes), I had to set organization_feature waffle flag to False. To test Domain Suborganization form (suborganization combo box), I had to set organization_feature waffle flag to True.

Code Review Verification Steps

As the original developer, I have

Satisfied acceptance criteria and met development standards

  • Met the acceptance criteria, or will meet them in a subsequent PR
  • Created/modified automated tests
  • Update documentation in READMEs and/or onboarding guide

Ensured code standards are met (Original Developer)

  • If any updated dependencies on Pipfile, also update dependencies in requirements.txt.
  • Interactions with external systems are wrapped in try/except
  • Error handling exists for unusual or missing values

Validated user-facing changes (if applicable)

  • Tag @dotgov-designers in this PR's Reviewers for design review. If code is not user-facing, delete design reviewer checklist
  • Verify new pages have been added to .pa11yci file so that they will be tested with our automated accessibility testing
  • Checked keyboard navigability
  • Tested general usability, landmarks, page header structure, and links with a screen reader (such as Voiceover or ANDI)

As a code reviewer, I have

Reviewed, tested, and left feedback about the changes

  • Pulled this branch locally and tested it
  • Verified code meets all checks above. Address any checks that are not satisfied
  • Reviewed this code and left comments. Indicate if comments must be addressed before code is merged
  • Checked that all code is adequately covered by tests
  • Verify migrations are valid and do not conflict with existing migrations

Validated user-facing changes as a developer

Note: Multiple code reviewers can share the checklists above, a second reviewer should not make a duplicate checklist. All checks should be checked before approving, even those labeled N/A.

  • New pages have been added to .pa11yci file so that they will be tested with our automated accessibility testing
  • Checked keyboard navigability
  • Meets all designs and user flows provided by design/product
  • Tested general usability, landmarks, page header structure, and links with a screen reader (such as Voiceover or ANDI)
  • (Rarely needed) Tested as both an analyst and applicant user

As a designer reviewer, I have

Verified that the changes match the design intention

  • Checked that the design translated visually
  • Checked behavior. Comment any found issues or broken flows.
  • Checked different states (empty, one, some, error)
  • Checked for landmarks, page heading structure, and links

Validated user-facing changes as a designer

  • Checked keyboard navigability
  • Tested general usability, landmarks, page header structure, and links with a screen reader (such as Voiceover or ANDI)
  • Tested with multiple browsers (check off which ones were used)
    • Chrome
    • Microsoft Edge
    • FireFox
    • Safari
  • (Rarely needed) Tested as both an analyst and applicant user

References

Screenshots

Domain Request Organization form with Federal Agency and State combo boxes:
image

Domain Suborganization form:
image

Copy link

github-actions bot commented Jan 6, 2025

🥳 Successfully deployed to developer sandbox bob.

@rachidatecs rachidatecs self-assigned this Jan 6, 2025
Copy link

github-actions bot commented Jan 6, 2025

🥳 Successfully deployed to developer sandbox bob.

@dave-kennedy-ecs dave-kennedy-ecs requested review from Katherine-Osos and a team January 6, 2025 19:44
Copy link
Contributor

@rachidatecs rachidatecs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line ending in one file

src/registrar/forms/utility/combobox.py Outdated Show resolved Hide resolved
@gabydisarli gabydisarli requested review from gabydisarli and removed request for a team January 6, 2025 22:17
@gabydisarli
Copy link
Contributor

Noticed a weird bug on the suborganization dropdown, when I have an option selected and then go to select another option. Both the selected option and the "—" option are highlighted in blue.
Screenshot 2025-01-08 at 9 15 37 PM

In the USWDS component, only the selected item will be highlighted when the dropdown is opened.
Screenshot 2025-01-08 at 9 17 04 PM

@gabydisarli
Copy link
Contributor

@dave-kennedy-ecs I'm not seeing the combo box applied on the state, territory, and military post dropdowns (last AC).

@gabydisarli
Copy link
Contributor

Noticed the same bug I saw on the Suborganization combo box also on the federal agency combo box in the request form
Screenshot 2025-01-08 at 9 33 57 PM

@gabydisarli
Copy link
Contributor

gabydisarli commented Jan 9, 2025

@dave-kennedy-ecs I'm not seeing the combo box applied on the state, territory, and military post dropdowns (last AC).

Correction, I am seeing it on the non-org model domain request, but it wasn't on the organization page on org model or domain management organization page (non-org model).

Copy link

🥳 Successfully deployed to developer sandbox bob.

Copy link

🥳 Successfully deployed to developer sandbox bob.

@dave-kennedy-ecs
Copy link
Contributor Author

Noticed a weird bug on the suborganization dropdown, when I have an option selected and then go to select another option. Both the selected option and the "—" option are highlighted in blue.

@gabydisarli thank you for catching this. I fixed this bug. It should now work as before.

Copy link

🥳 Successfully deployed to developer sandbox bob.

@dave-kennedy-ecs
Copy link
Contributor Author

@dave-kennedy-ecs I'm not seeing the combo box applied on the state, territory, and military post dropdowns (last AC).

Correction, I am seeing it on the non-org model domain request, but it wasn't on the organization page on org model or domain management organization page (non-org model).

@gabydisarli I fixed these as well. Sorry, I was having trouble initially understanding the ACs and missed a few selects that I was supposed to change to comboboxes. I think I now have all the requested cases as comboboxes rather than selects.

Copy link

🥳 Successfully deployed to developer sandbox bob.

@dave-kennedy-ecs
Copy link
Contributor Author

image
Added combobox for State/Territory in organization edit form.

Copy link

🥳 Successfully deployed to developer sandbox bob.

Copy link
Contributor

@zandercymatics zandercymatics left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like the requesting entity page (portfolio domain request) is throwing a js error! The "Add suborganization information" box should be hidden on page load for new requests.
image

By default, this page adds a 'fake' option called "other" to this dropdown to track if they are requesting a new suborganization (#2771). Its likely failing on that part of it
image

Copy link

🥳 Successfully deployed to developer sandbox bob.

@dave-kennedy-ecs
Copy link
Contributor Author

Can you also change the suborganization dropdown to a combobox on the Requesting Entity page in the org model request form, please?

Done

@dave-kennedy-ecs
Copy link
Contributor Author

Hmmm, I tried clearing my browser cache, and then tried the disabling of the cache through dev tools. To disable in Dev tools, I opened dev tools, went to settings, and checked "Disable cache while DevTools is open." Was that correct? Screenshot 2025-01-13 at 4 02 40 PM

This bug is now fixed

@dave-kennedy-ecs
Copy link
Contributor Author

Looks like the requesting entity page (portfolio domain request) is throwing a js error! The "Add suborganization information" box should be hidden on page load for new requests. image

By default, this page adds a 'fake' option called "other" to this dropdown to track if they are requesting a new suborganization (#2771). Its likely failing on that part of it image

This bug is now fixed

Copy link

🥳 Successfully deployed to developer sandbox bob.

1 similar comment
Copy link

🥳 Successfully deployed to developer sandbox bob.

Copy link

🥳 Successfully deployed to developer sandbox bob.

@zandercymatics
Copy link
Contributor

Two additional observations:

  1. The "other" option in suborg isn't auto-selected when renavigating to the page
  2. The search bar is not cleared on click so you have to clear that text first

@zandercymatics
Copy link
Contributor

@gabydisarli

Copy link

🥳 Successfully deployed to developer sandbox bob.

@gabydisarli
Copy link
Contributor

Thanks @zandercymatics I'll take a look at those items you pointed out when the PR is ready to review again

Copy link

🥳 Successfully deployed to developer sandbox bob.

Copy link

🥳 Successfully deployed to developer sandbox bob.

1 similar comment
Copy link

🥳 Successfully deployed to developer sandbox bob.

Comment on lines -40 to -44
// Add fake "other" option to sub_organization select
if (select && !Array.from(select.options).some(option => option.value === "other")) {
select.add(new Option(subOrgCreateNewOption, "other"));
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Handling of 'other' has been moved from javascript to the form

Copy link
Contributor

@zandercymatics zandercymatics left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work. One question, though

is_requesting_new_suborganization = False
if self.initial and "is_requesting_new_suborganization" in self.initial:
# Call the method if it exists
is_requesting_new_suborganization = self.initial["is_requesting_new_suborganization"]()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This works, but why doesn't it throw a syntax error? Since is_requesting_new_suborganization is a field on the form. I know it is a function, too, though - so maybe some magic is going over my head here

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is_requesting_new_suborganization is a field in the form. The form initialization, specifically get_initial_for_field, sets the field to the callable method on the (existing) object. this is how it can be called on line 152. note that this line is only called during a GET, not during a POST, so there isn't a conflict between the input submitted from a form, and the value initialized from the db object

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Change some dropdowns from Select component to Combo box on request form and management pages
4 participants