magento / magento2-page-builder

Magento2 PageBuilder
Other
79 stars 59 forks source link

Fix #866: Add element existence check to prevent Page Builder editor crashes #873

Open artttj opened 1 month ago

artttj commented 1 month ago

Description

We encountered a scenario where missing HTML elements in Page Builder led to runtime errors due to direct calls to setAttribute.

To address this, we added an existence check before setting attributes. This change prevents the editor from breaking and improves stability by handling cases where elements are missing.

Ideally, the core should include such checks to enhance overall resilience and user experience.

Story

N/A

Bug

N/A

Task

N/A

Fixed Issues

  1. magento/magento2-page-builder#866: Graceful Handling of Null element in Page Builder to Prevent Editor Failure

Builds

N/A

Related Pull Requests

N/A

Manual Testing Scenarios

Please test the following scenarios to verify the changes:

  1. Remove data-pb-style Attribute:

    • Remove the data-pb-style attribute from an element with applied styles.
    • Ensure the Page Builder continues to work without issues.
  2. Modify data-pb-style Hash:

    • Change the data-pb-style attribute's value to a non-relevant hash.
    • Confirm that the Page Builder handles this gracefully and remains functional.
  3. Remove HTML Element:

    • Delete the HTML element to which styles are applied.
    • Check that the Page Builder does not crash and continues to operate normally.

Note: This issue was observed when using the DeepL API, but similar problems might occur in other scenarios. The preview editor should remain stable.

Questions or comments

N/A

Checklist

artttj commented 1 month ago

@magento run all tests