Skip to content

Graceful Handling of Null element in Page Builder to Prevent Editor Failure #866

Open
@Stevie-Ray

Description

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:

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.

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    • Status

      Ready for Grooming

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions