magento / magento2

Prior to making any Submission(s), you must sign an Adobe Contributor License Agreement, available here at: https://opensource.adobe.com/cla.html. All Submissions you make to Adobe Inc. and its affiliates, assigns and subsidiaries (collectively “Adobe”) are subject to the terms of the Adobe Contributor License Agreement.
http://www.magento.com
Open Software License 3.0
11.27k stars 9.27k forks source link

Pagebuilder content type extension mobile responsive bug | Prevents developers extending mobile functionality #38565

Open RickyGoacher opened 1 month ago

RickyGoacher commented 1 month ago

Preconditions and environment

When attempting to extend a pagebuilder content type to add in additional functionality, if the content type already has an extension by default to add in the min-height option on mobile, the js/converter/style/min-height.js file will error preventing the user from saving the page or block.

This error is caused by the min-height input on mobile having an empty value, which is then returned as undefined by the min-height.js file.

image

The return statement in the toDom function cannot handle an undefined value.

return value.split(/\+|\-|\*|\//).length > 1 ? "calc(" + (0, _object.get)(data, name) + ")" : value;

Adding a conditional to check if value !== undefined prevents the error and allows the admin user to save the changes for the page or block.

if(value !== undefined) {
  return value.split(/\+|\-|\*|\//).length > 1 ? "calc(" + (0, _object.get)(data, name) + ")" : value;
}

Or adding a conditional to set the value of value if it's undefined

if(value === undefined) {
  value = '100px';
}

This error prevents developers from adding additional functionality to pagebuilder for mobile devices and i believe it also adds to the confusion when it comes to developing for pagebuilder.

Steps to reproduce

  1. Create an extension for a pagebuilder content type that already has a mobile form. For example, the banner content type or the row. (Confirm it has the min_heightmobile option).
  2. Attempt to add additional functionality, for example an input or colour selector that if different for both mobile and desktop.
  3. Once the new functionality has been added, attempt to use it.
  4. Add a value on Desktop view, switch to mobile and add the mobile value, then attempt to save the page.
  5. The page wont save and will throw the error - Cannot read properties of undefined (reading 'split') Screenshot from 2024-04-02 11-13-45

Expected result

Extending pagebuilder content types which have the min-height option should not result in an error preventing the user from saving the page or block.

This prevents developers extending content types for mobile.

Actual result

Attempting to extend pagebuilder content types (which already have a mobile form) to add additional functionality for mobile view results in an error being thrown frommin-height.js and prevents the user from saving the page or block. Screenshot from 2024-04-02 11-13-45

Additional information

Screenshot from 2024-04-02 11-13-45

Release note

No response

Triage and priority

m2-assistant[bot] commented 1 month ago

Hi @RickyGoacher. Thank you for your report. To speed up processing of this issue, make sure that the issue is reproducible on the vanilla Magento instance following Steps to reproduce. To deploy vanilla Magento instance on our environment, Add a comment to the issue:

m2-assistant[bot] commented 4 weeks ago

Hi @engcom-Hotel. Thank you for working on this issue. In order to make sure that issue has enough information and ready for development, please read and check the following instruction: :point_down:

engcom-Hotel commented 4 weeks ago

Hello @RickyGoacher,

Thanks for the report and collaboration!

We have tried to reproduce the issue in the latest development branch ie 2.4-develop but the issue is not reproducible for us.

We have created the below module to reproduce the issue, please find attached the same for reference: Magz.zip

We are able to save for both Desktop and Mobile versions. Please let us know if we missed anything.

Thanks

RickyGoacher commented 4 weeks ago

Hi @engcom-Hotel ,

Thanks for taking a look at this. Looking at the module you've attached I can see that you have created a new content type. The issue here is with extending the default content types that already have a mobile form under ui_components For example the banner content type: image

Extending this mobile form pagebuilder_banner_mobile_form.xml, or any other mobile form available by default causes the error mentioned.

I've attached an example of this below. Example.zip

In this example I've added the option to change the overlay colour for the banner on mobile. image

By setting the overlay colour on Desktop view, then switching to mobile view and setting the colour for mobile, the error will appear when you attempt to save the page. (Some times also while switching between mobile and desktop view)

Desktop image

Mobile image

Error in console image

This issue occurs because all the default content types with mobile form have a mobile min-height option. This is why we see the min-height error.

engcom-Hotel commented 2 weeks ago

Hello @RickyGoacher,

Thanks for the updates!

We are now able to reproduce the issue. Please have a look into the below screenshot for reference:

image

Hence confirming the issue.

Thanks

github-jira-sync-bot commented 2 weeks ago

:white_check_mark: Jira issue https://jira.corp.adobe.com/browse/AC-11826 is successfully created for this GitHub issue.

m2-assistant[bot] commented 2 weeks ago

:white_check_mark: Confirmed by @engcom-Hotel. Thank you for verifying the issue.
Issue Available: @engcom-Hotel, You will be automatically unassigned. Contributors/Maintainers can claim this issue to continue. To reclaim and continue work, reassign the ticket to yourself.