Open Stevie-Ray opened 8 months ago
Hi @Stevie-Ray. Thank you for your report.
To speed up processing of this issue, make sure that you provided sufficient information.
Add a comment to assign the issue: @magento I am working on this
Join Magento Community Engineering Slack and ask your questions in #github channel.
@magento I am working on this
I've encountered a scenario where the Page Builder's HTML content can become corrupted, leading to potential runtime errors in the script responsible for handling HTML elements. Specifically, the issue arises from the code segment designed to apply styles by setting attributes on elements selected via a CSS selector. When the expected HTML element is absent (null), attempting to call setAttribute on it directly causes the entire Page Builder to halt, preventing users from further editing their pages.
The code segment can be found here:
https://github.com/magento/magento2-page-builder/blob/9f615d8973ac1923c94ed1aa8a42bfb6b47b7345/app/code/Magento/PageBuilder/view/adminhtml/web/ts/js/stage-builder.ts#L64
To enhance the resilience of the Page Builder and ensure that such HTML content issues do not disrupt the editing process, I propose adding a simple existence check for the element before attempting to call setAttribute on it. This small safeguard will allow the rest of the Page Builder's functionality to continue operating normally, even if specific elements are not found, thereby improving the user experience and stability of the editor in edge cases.
Implementing this change could significantly reduce the impact of content errors on the Page Builder's usability, ensuring that clients can continue editing their pages without interruption.
This rewrite aims to clearly describe the issue, its impact on the user experience, and propose a specific solution, making it easier for the Magento development team to understand and address the problem.