Postal addresses: show the country's flag, as the telephone field does #214
Labels
No labels
accessibility
authentication
breaking change
bug
documentation
enhancement
interface
internationalisation
observability
security
tier
1
tier
2
tier
3
tier/4
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Postulo/postulo#214
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
The Country chooser in a postal address row is a plain list of names with no flag, while the country chooser beside every telephone number shows the chosen country's flag (#53, #88). Addresses should show it too, the same way.
What it is today
src/postulo/templates/partials/postal_addresses.html:52-55, on Your details and the contact form while Several postal addresses is on:It is a plain Django
ChoiceField(core/postal.py:169-175). Its choices come fromphones.country_choices(), which lists country names with no dialling codes, so the list is already right for an address; it only lacks the flag.What already exists to reuse
The telephone field solved exactly this, and the address chooser uses the same list of countries:
partials/phone_widget.html:21-34.<option>carries its own flag's URL indata-flag="{% flag_url option.value %}", because static files are served under a content hash and a script cannot build the URL itself.ps-9to make room for the flag, andmin-w-0, so it can shrink.static/js/app.js:23-57follows the select onchange, delegated from the document. It is keyed on[data-phone-country]and finds the flag holder through[data-phone-flag].{% flag %}tag draws the right flag for the value the row loaded with, so the field is correct with scripts off; it only stops following the select until the form is saved.tests/test_flags.py::test_the_list_holds_every_country_the_telephone_field_offersalready guarantees a flag for every country inphones.COUNTRIES, the same list the address chooser offers, so no new artwork is needed.What a fix has to settle
partials/country_select.html.data-country-select/data-country-flag, instead of teaching it a second pair of names.tests/e2e/test_phone_flag.pypins it.alt=""andaria-hidden="true". The country name in the select already says which country it is.sm:grid-cols-2,:47), so it is wider than the phone field's fixedw-40and the flag has room. Check it at phone width, where the columns stack.row.labels_for_country, #147), not the one just chosen. That does not change here, but the flag makes it more obvious that the country was changed and the labels were not. Note it, and file separately if it should follow live.start-2.5andps-9, as the phone widget uses;tests/test_template_lint.pyfails onleft/pl.Checks
data-flagon every country option and draws the flag for the country it loaded with;tests/e2e/test_accessibility.pyvisits Your details and the contact form; axe stays clean in both themes and right to left. Extendtest_phone_flag.py(or add a sibling) to change an address's country and see the flag follow.npm run build:cssif new classes appear.