-
Notifications
You must be signed in to change notification settings - Fork 9.4k
Issue 30286 - Fix widget layout update removal button to work for multiple layout updates #30992
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 30286 - Fix widget layout update removal button to work for multiple layout updates #30992
Conversation
…ock to directly in the template to prevent inaccurate js element selection in SecureHtmlRenderer event listener generation.
…ayout buttons work as expected.
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!. Description clearly to me. But seem a reason previously core team remove this code onclick in template that lead to this issue Oh my! Magento now handle click event in php code instead html like before. Maybe this code line here will affect to all element have click event (button, anchor) |
@magento run all tests |
Magento 2.4I am facing the same issue in my project. Did anyone found any solution to this issue? Thank you. |
@bhaveshpp https://patch-diff.githubusercontent.com/raw/magento/magento2/pull/30992.diff layout.phtml is the only file that really needs to be updated to fix the issue. |
@magento run all tests |
@magento run Functional Tests B2B |
@rogyar i think this patch from @zaximus84 is better fix and simplest . Can we have further check and approve this soon ? |
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.
The failing tests are not related to the current changeset
Hi @rogyar, thank you for the review. |
@magento run all tests |
… work for multiple layout updates #30992
Hi @zaximus84, thank you for your contribution! |
Description (*)
When adding a widget in the Magento admin (Content > Widgets), the remove button (trash can icon) on layout updates doesn't work for any layout update but the first. This is because the current code relies on \Magento\Framework\View\Helper\SecureHtmlRenderer::renderEventListenerAsTag to generate the js click listeners, and that uses document.querySelector to establish the element. The element selector passed to querySelector is not unique because it comes from javascript templating, and it always selects the first matching element on the page. Every time the "Add Layout Button" is clicked, another layout row is added, but the click handler is just added to the first row again.
Using a widget block (PHP) class in combination with javascript templating to produce the click listeners doesn't work for this scenario, so this PR updates the remove buttons to use a standard onclick attribute. It also updates the new widget MFTF test to add and remove layout rows and confirm the resulting counts.
Fixed Issues (if relevant)
Manual testing scenarios (*)
Contribution checklist (*)