Skip to content

ISSUE-30265 - Fix product add / remove in Safari when creating an order in admin #31022

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

Conversation

zaximus84
Copy link

Description (*)

When creating an order in admin in Safari, adding a product to the order results in an endless load spinner. The page has to be refreshed (and then reflects the added product). Same when removing a product. This PR fixes this behavior in Safari.

Product management works by submitting a form to an iframe. An onload listener is attached to the iframe, and this is what removes the loading spinner and updates the order contents to reflect added or removed products. Commit 499d43d changed the iframe selector in the js to use :last-of-type. This is the underlying problem. Safari fails to find the iframe and attach the onload listener. Removing :last-of-type from the selector, or even wrapping the js in setTimeout with a 1 ms delay fixes the problem.

It looks like this is a timing / sequence issue specific to Safari with regard to DOM render and the use of :last-of-type. I theorize that, because last-of-type examines siblings of the same parent, a query with last-of-type will not properly match elements until the DOM for the parent is complete. Because the js is right after the iframe (within the parent div), the parent DOM is not complete when the js runs.

To solve this, I simply moved the javascript to the bottom of the template, outside the div that wraps the iframe. Safari now locates the iframe on page load and attaches the onload listener as expected.

Fixed Issues (if relevant)

  1. Fixes SAFARI: endless deploy when admin try to add product in order #30265

Manual testing scenarios (*)

Using Safari:

  1. Go admin - Sales - Create New Order
  2. Select any customer from grid
  3. Click Add Products
  4. Select any Product, enter quantity
  5. Click add "selected products to order" button
  6. Confirm that the loading spinner only appears for a moment before disappearing, and the product is then reflected in the order.
  7. Remove the product and confirm the same result.

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)

…can properly query for last-of-type on page load.
@m2-assistant
Copy link

m2-assistant bot commented Nov 23, 2020

Hi @zaximus84. 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.4-develop instance - deploy vanilla Magento instance

❗ Automated tests can be triggered manually with an appropriate comment:

  • @magento run all tests - run or re-run all required tests against the PR changes
  • @magento run <test-build(s)> - run or re-run specific test build(s)
    For example: @magento run Unit Tests

<test-build(s)> is a comma-separated list of build names. Allowed build names are:

  1. Database Compare
  2. Functional Tests CE
  3. Functional Tests EE,
  4. Functional Tests B2B
  5. Integration Tests
  6. Magento Health Index
  7. Sample Data Tests CE
  8. Sample Data Tests EE
  9. Sample Data Tests B2B
  10. Static Tests
  11. Unit Tests
  12. WebAPI Tests

You can find more information about the builds here

ℹ️ Please run only needed test builds instead of all when developing. Please run all test builds before sending your PR for review.

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

⚠️ According to the Magento Contribution requirements, all Pull Requests must go through the Community Contributions Triage process. Community Contributions Triage is a public meeting.

🕙 You can find the schedule on the Magento Community Calendar page.

📞 The triage of Pull Requests happens in the queue order. If you want to speed up the delivery of your contribution, please join the Community Contributions Triage session to discuss the appropriate ticket.

🎥 You can find the recording of the previous Community Contributions Triage on the Magento Youtube Channel

✏️ Feel free to post questions/proposals/feedback related to the Community Contributions Triage process to the corresponding Slack Channel

@m2-community-project m2-community-project bot added Priority: P2 A defect with this priority could have functionality issues which are not to expectations. Severity: S2 Major restrictions or short-term circumventions are required until a fix is available. labels Nov 23, 2020
@ihor-sviziev ihor-sviziev self-assigned this Nov 24, 2020
@ihor-sviziev ihor-sviziev added Auto-Tests: Not Required Changes in Pull Request does not require coverage by auto-tests Award: bug fix Progress: pending review and removed Progress: review labels Nov 24, 2020
@ihor-sviziev
Copy link
Contributor

Good catch! 👍let’s run the tests
@magento run all tests

@ihor-sviziev
Copy link
Contributor

@magento run Database Compare, Integration Tests

@ihor-sviziev
Copy link
Contributor

@magento run WebAPI Tests

Copy link
Contributor

@gabrieldagama gabrieldagama left a comment

Choose a reason for hiding this comment

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

Hi @zaximus84, thanks for your contribution! The failed tests aren't related to the changes.

@magento-engcom-team
Copy link
Contributor

Hi @gabrieldagama, thank you for the review.
ENGCOM-8486 has been created to process this Pull Request

@magento-deployment-service
Copy link

Hi @engcom-Alfa. Thank you for your request. I'm working on Magento instance for you.

@magento-deployment-service
Copy link

@engcom-Alfa engcom-Alfa self-assigned this Nov 29, 2020
@engcom-Alfa
Copy link
Contributor

@magento give me 2.4-develop instance

@magento-deployment-service
Copy link

Hi @engcom-Alfa. Thank you for your request. I'm working on Magento instance for you.

@magento-deployment-service
Copy link

@soleksii
Copy link

@magento give me test instance

@magento-deployment-service
Copy link

Hi @stoleksiy. Thank you for your request. I'm working on Magento instance for you.

@magento-deployment-service
Copy link

Hi @stoleksiy, here is your Magento Instance: https://cf092ed0f5790b456512eb811f6efaa0.instances.magento-community.engineering
Admin access: https://cf092ed0f5790b456512eb811f6efaa0.instances.magento-community.engineering/admin_4b2d
Login: b0ee8361
Password: 11b89c41d6f8

@engcom-Alfa
Copy link
Contributor

✔️ QA Passed

Manual testing scenario:

  1. Go admin - Sales - Create New Order
  2. Select any customer from grid
  3. Click Add Products
  4. Select any Product, enter quantity
  5. Click the add "selected products to order" button

Safari

Before: ✖️ Endless deploy icon appears.

Screen-Recording-2020-11-29-at-1

After: ✔️ Product is added to order and removed

Screen-Recording-2020-11-29-at-1 (1)

Chrome

After: ✔️ Product is added to order and removed

chrome

Firefox

After: ✔️ Product is added to order and removed

Peek 2020-11-30 11-32

@m2-assistant
Copy link

m2-assistant bot commented Dec 10, 2020

Hi @zaximus84, thank you for your contribution!
Please, complete Contribution Survey, it will take less than a minute.
Your feedback will help us to improve contribution process.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: Frontend Auto-Tests: Not Required Changes in Pull Request does not require coverage by auto-tests Award: bug fix Award: category of expertise Component: Catalog Partner: Blue Acorn iCi partners-contribution Pull Request is created by Magento Partner Priority: P2 A defect with this priority could have functionality issues which are not to expectations. Progress: accept QA: Added to Regression Scope Scenario was analysed and added to Regression Testing Scope Release Line: 2.4 Severity: S2 Major restrictions or short-term circumventions are required until a fix is available.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

SAFARI: endless deploy when admin try to add product in order
7 participants