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

Fix #25350 - Some JS removes State/Province field for United Kingdom for example #25386

Open
wants to merge 1 commit into
base: 2.4-develop
Choose a base branch
from

Conversation

Bartlomiejsz
Copy link
Contributor

@Bartlomiejsz Bartlomiejsz commented Oct 30, 2019

Description (*)

This is fix for #25350

Fixed Issues (if relevant)

  1. Fixes Some JS removes State/Province field for United Kingdom for example #25350: Some JS removes State/Province field for United Kingdom for example

Manual testing scenarios (*)

  1. Click Address Book
  2. Select the United Kingdom as a country
  3. Set Postcode to AB12 3CD
  4. Set State/Province to Greater London
  5. Set City to London
  6. Save address.
  7. Verify that you see "Greater London" in Default Shipping and Default Billing address
  8. Click Change Billing Address

Expected result (*)

Greater London is in the State/Province input

Questions or comments

Contribution checklist (*)

  • Pull request has a meaningful description of its purpose
  • All commits are accompanied by meaningful commit messages
  • All new or changed code is covered with unit/integration tests (if applicable)
  • All automated tests passed successfully (all builds are green)

@m2-assistant
Copy link

m2-assistant bot commented Oct 30, 2019

Hi @Bartlomiejsz. Thank you for your contribution
Here is some useful tips how you can test your changes using Magento test environment.
Add the comment under your pull request to deploy test or vanilla Magento instance:

  • @magento give me test instance - deploy test instance based on PR changes
  • @magento give me 2.3-develop instance - deploy vanilla Magento instance

For more details, please, review the Magento Contributor Guide documentation.

Copy link
Contributor

@krzksz krzksz left a comment

Choose a reason for hiding this comment

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

Hey @Bartlomiejsz, thanks for the contribution! I have trouble to understand the extensiveness of this change, I can see you are also refactoring helpers but was it really required to touch PHP files at all? I did some short debugging and following changes inside _updateRegion method solved the issue for me and cleaned up the code a bit:

  1. Move regionInput.val(''); below if (this.options.regionJson[country]) { as this clearing input field every time.
  2. Extract this._removeSelectOptions(regionList); above if...else because it is present in both of them anyway.
  3. Remove $(regionList).find('option:selected').removeAttr('selected'); as all the options are removed by the above call anyway.

Can you please check if those changes would be ok for you once you apply them? If so, feel free to update the PR.

@ghost ghost assigned krzksz Nov 21, 2019
@Bartlomiejsz
Copy link
Contributor Author

Hi @krzksz, I'll check those changes as soon as possible, now only regarding php files being changed - this indeed wasn't required in terms of functional changes here and in first version of PR those were not modified. I modified those later to fix failing static tests ($this shouldn't be used in phtml files)

@Bartlomiejsz
Copy link
Contributor Author

Hi @krzksz, I applied changes you requested, please review :)

@Bartlomiejsz
Copy link
Contributor Author

Hi @krzksz, you're right, added this one change. I also noticed one additional issue, if you select some country which have regions list as select (i.e. USA), select one of regions, then switch to another country with also regions select (like Poland). Then Region select becomes empty (even without default message to choose option). I modified then saving of current region in same manner as introduced in this PR for text input - per country.

@magento-engcom-team
Copy link
Contributor

Hi @krzksz, thank you for the review.
ENGCOM-6318 has been created to process this Pull Request
✳️ @krzksz, could you please add one of the following labels to the Pull Request?

Label Description
Auto-Tests: Covered All changes in Pull Request is covered by auto-tests
Auto-Tests: Not Covered Changes in Pull Request requires coverage by auto-tests
Auto-Tests: Not Required Changes in Pull Request does not require coverage by auto-tests

@engcom-Bravo engcom-Bravo self-assigned this Nov 24, 2019
@engcom-Bravo
Copy link
Contributor

Hello @krzksz. Would You please mark this PR with an appropriate label. Thank You.

@krzksz krzksz added the Auto-Tests: Not Covered Changes in Pull Request requires coverage by auto-tests label Nov 25, 2019
@krzksz
Copy link
Contributor

krzksz commented Nov 25, 2019

@engcom-Bravo Done.

@engcom-Bravo
Copy link
Contributor

Hello @Bartlomiejsz. Thank You for Your contribution. In order for us to be able to further process Your PR please cover it with the appropriate auto-tests. Thank You.

@Bartlomiejsz
Copy link
Contributor Author

Hi @engcom-Bravo, sorry but what exactly should be covered with tests here? In my previous PRs all javascript changes were marked as Auto Tests: Not Required, ViewModel I added is simply returning existing helpers and it's addition I already included in dev/tests/integration/testsuite/Magento/Customer/Block/Form/RegisterTest.php.

@engcom-Echo
Copy link
Contributor

@magento run all tests

@Bartlomiejsz Bartlomiejsz force-pushed the feature/fix_25350_region_field_cleared branch from 004b155 to b73e29e Compare February 9, 2020 00:32
@Bartlomiejsz
Copy link
Contributor Author

Hi @krzksz, since #26285 introduced ViewModel used for similar goal that I achieved with one created here, and both changes together resulted in conflicts, I rebased my changes onto 2.4-develop and instead of creating my own ViewModel I used one created in mentioned PR. Please review again if possible

@ptylek
Copy link
Contributor

ptylek commented Mar 7, 2020

@Bartlomiejsz this branch has conflicts that must be resolved

@Bartlomiejsz Bartlomiejsz force-pushed the feature/fix_25350_region_field_cleared branch from b73e29e to b3ad17f Compare March 9, 2020 10:30
@Bartlomiejsz
Copy link
Contributor Author

@ptylek done, resolved

@Bartlomiejsz Bartlomiejsz force-pushed the feature/fix_25350_region_field_cleared branch from b3ad17f to c98f29e Compare March 9, 2020 12:39
@ghost ghost added Severity: S2 Major restrictions or short-term circumventions are required until a fix is available. Priority: P3 May be fixed according to the position in the backlog. labels May 28, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: Frontend Auto-Tests: Not Covered Changes in Pull Request requires coverage by auto-tests Component: Checkout Component: Customer Partner: Fast White Cat partners-contribution Pull Request is created by Magento Partner Priority: P3 May be fixed according to the position in the backlog. Progress: pending review Release Line: 2.4 Severity: S2 Major restrictions or short-term circumventions are required until a fix is available. Squashtoberfest 2019
Projects
Status: Pending Review
Development

Successfully merging this pull request may close these issues.

Some JS removes State/Province field for United Kingdom for example
7 participants