-
Notifications
You must be signed in to change notification settings - Fork 9.4k
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
ISSUE-30265 - Fix product add / remove in Safari when creating an order in admin #31022
Conversation
…can properly query for last-of-type on page load.
Hi @zaximus84. Thank you for your contribution
❗ Automated tests can be triggered manually with an appropriate comment:
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. 🕙 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 |
Good catch! 👍let’s run the tests |
@magento run Database Compare, Integration Tests |
@magento run WebAPI Tests |
There was a problem hiding this 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.
Hi @gabrieldagama, thank you for the review. |
Hi @engcom-Alfa. Thank you for your request. I'm working on Magento instance for you. |
Hi @engcom-Alfa, here is your Magento Instance: https://cf092ed0f5790b456512eb811f6efaa0-2-4-develop.instances.magento-community.engineering |
@magento give me 2.4-develop instance |
Hi @engcom-Alfa. Thank you for your request. I'm working on Magento instance for you. |
Hi @engcom-Alfa, here is your Magento Instance: https://cf092ed0f5790b456512eb811f6efaa0-2-4-develop.instances.magento-community.engineering |
@magento give me test instance |
Hi @stoleksiy. Thank you for your request. I'm working on Magento instance for you. |
Hi @stoleksiy, here is your Magento Instance: https://cf092ed0f5790b456512eb811f6efaa0.instances.magento-community.engineering |
✔️ QA Passed Manual testing scenario:
Safari Before: ✖️ Endless deploy icon appears. After: ✔️ Product is added to order and removed Chrome After: ✔️ Product is added to order and removed Firefox After: ✔️ Product is added to order and removed |
…eating an order in admin #31022
Hi @zaximus84, thank you for your contribution! |
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)
Manual testing scenarios (*)
Using Safari:
Contribution checklist (*)