Skip to content

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

Description

@Stevie-Ray

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions