Conversation
|
Thanks for the pull request, @RomkaSk! This repository is currently maintained by Once you've gone through the following steps feel free to tag them in a comment and let them know that your changes are ready for engineering review. 🔘 Get product approvalIf you haven't already, check this list to see if your contribution needs to go through the product review process.
🔘 Provide contextTo help your reviewers and other members of the community understand the purpose and larger context of your changes, feel free to add as much of the following information to the PR description as you can:
🔘 Submit a signed contributor agreement (CLA)
If you've signed an agreement in the past, you may need to re-sign. Once you've signed the CLA, please allow 1 business day for it to be processed. 🔘 Get a green buildIf one or more checks are failing, continue working on your changes until this is no longer the case and your build turns green. DetailsWhere can I find more information?If you'd like to get more details on all aspects of the review process for open source pull requests (OSPRs), check out the following resources: When can I expect my changes to be merged?Our goal is to get community contributions seen and reviewed as efficiently as possible. However, the amount of time that it takes to review and merge a PR can vary significantly based on factors such as:
💡 As a result it may take up to several weeks or months to complete a review and merge your PR. |
|
Verawood backport #1402 |
|
Hi @RomkaSk! Welcome, and thank you for this contribution! In order for your CLA check to turn green, you'll need to submit a CLA form. If you are contributing as an individual, please fill out the individual CLA form here. If you are contributing on behalf of an organization, please have your manager reach out to oscm@axim.org so you may be added to your org's existing entity agreement. Please let me know if you have any questions. Thanks! |
Description
On the learner profile page the Country selector renders with a single empty placeholder option - no countries can be selected.
This happens on any deployment that keeps the platform default
REGISTRATION_EXTRA_FIELDS['country'] = 'hidden'(edx-platform: openedx/envs/common.py:1679).Steps to reproduce
REGISTRATION_EXTRA_FIELDS['country']at its default'hidden'(no Site Configuration override)./profile/u/<username>.Expected: the localized list of countries, as on the Account Settings page.
Actual: the
<select id="country">contains only the empty placeholder — 1 option, 0 countries.Root cause
The profile builds its list of selectable countries from the registration form description, not from a country/locale source:
src/profile/data/sagas.js:43-63src/profile/data/services.js:158getCountryList()→GET {LMS_BASE_URL}/user_api/v1/account/registration/src/profile/data/services.js:152extractCountryList()takesfields[name == 'country'].options, maps them to codes; returns[]on any misssrc/profile/data/actions.js:21→src/profile/data/reducers.js:66state.profilePage.countriesCodesListsrc/profile/data/selectors.js:93-103sortedCountriesSelectorfilters the full localized list by those codesThe registration endpoint only includes a
countryfield when the registration form is configured to show it. With the default'hidden',countriesCodesListarrives as[]and the filter is still applied unconditionally:Every entry is removed. Only the learner's already-committed country survives, so an account with no country set is left with nothing to choose from.
[]also arrives when the request fails (services.js:164logs and returns[]), so a transient error produces the same dead dropdown.Regression
Introduced by #1185 (29edfa9, feat: added restricted country functionality), which replaced
with the allow-list filter. The intent was to hide embargoed countries, but the registration form was used as a proxy for "not embargoed" — which only holds on sites where country is part of signup.
Why Account Settings is not affected
frontend-app-accountuses the same endpoint and the sameextractCountryList()(src/account-settings/data/service.js:191-202), so itscountriesCodesListis empty too. It renders correctly because it guards the empty case (AccountSettingsPage.jsx#L167-L175):The per-option guard is present in both MFEs (
length > 0); only the list-level guard is missing in profile.Fix
Port the account MFE's guard into
sortedCountriesSelector— treat an empty list as "the LMS does not restrict the choice":Country.jsx:45isDisabledCountry()already short-circuits oncountriesCodesList.length > 0, so no other change is needed. Where the LMS does send an allow-list, behaviour is unchanged.One trade-off worth stating: on a site where embargo is enabled and
countryis hidden in registration, the profile will now offer an embargoed country and the learner will get the server-side field error on save. That is worse than not offering it, but strictly better than today's "no options at all", and it matches what Account Settings already does.How Has This Been Tested?
REGISTRATION_EXTRA_FIELDS: the country<select>had 1 option. Withcountrypresent in the registration response the same build showed 251 options, confirming the allow-list filter as the cause.src/profile/data/selectors.test.jswith three cases forsortedCountriesSelector: emptycountriesCodesListreturns the full list; a non-empty list filters to exactly those codes; the country already saved on the account is kept even if it is not in the list. The first case fails onmasterwithout this change and passes with it.npm run lintclean,npm run testgreen on Node 24: 14 suites, 85 tests, 5 snapshots. The existing mock stores carry a non-emptycountriesCodesList, so their snapshots are unchanged.Merge Checklist
Post-merge Checklist