Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

custom widget with wysiwyg problem on insert widget via pages or blocks #13409

Closed
deagleka opened this issue Jan 29, 2018 · 7 comments
Closed
Labels
Fixed in 2.3.x The issue has been fixed in 2.3 release line Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development Reproduced on 2.1.x The issue has been reproduced on latest 2.1 release Reproduced on 2.2.x The issue has been reproduced on latest 2.2 release Reproduced on 2.3.x The issue has been reproduced on latest 2.3 release

Comments

@deagleka
Copy link

Preconditions
Magento v2.2.2
Cache disabled

Steps to reproduce
1.created a custom widget with text field using editor to activate wysiwyg
widget.xml file:
<parameter name="custom_title" xsi:type="block" visible="true" required="true"> <label translate="true">Title</label><block class="VendorName\NameSpace\Block\Adminhtml\Widget\TextAreaField"/></parameter>

TextAreaField block:
$editor = $this->_factoryElement->create('editor', ['data' => $element->getData()])->setLabel('')->setWysiwyg(true) ->setConfig($this->getWysiwygConfig($element))->setForceLoad(true) ->setForm($element->getForm());

  1. Create custom widget with 2 different ways:
    a. via Admin -> Content -> Widgets : This works fine, everything is ok.
    b. via Admin -> Content -> Pages -> Home Page -> Content -> Insert Widget : Problem starting from here.

Expected result

  1. an image of Magento Widget should appear
    image
  2. if check via code, it should have this below code:
    {{widget type="VendorName\NameSpace\Block\Widget\CustomWidget" custom_title="abc" template="VendorName_NameSpace::widget/master-template.phtml"}}

Actual result

  1. If I turn off wysiwyg on my custom widget: it works fine.

  2. If I turn wysiwyg on: Image and Code doesnt show up.

  3. If I turn off wysiwyg and make my widget code appear -> then edit it by double click on the image -> change the text into wysiwyg -> save.
    The image still there, however if checking the value : content not change -> there is another widget image appear in the content if turn on wysiwyg.

Note
I think it is some kind of duplicate wysiwyg command mceInsertContent in lib/web/mage/adminhtml/wysiwyg/widget.js line 383
this.getWysiwyg().execCommand('mceInsertContent', false, content);

Hope this help. Have been stucked for this problem more than 2 days. Need help. Thank you.

@magento-engcom-team magento-engcom-team added the Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed label Jan 29, 2018
@magento-engcom-team
Copy link
Contributor

@deagleka , thank you for your report.
We were not able to reproduce this issue by following the steps you provided. Please provide more detailed steps to reproduce or try to reproduce this issue ona clean installation without third party code.

@deagleka
Copy link
Author

magento v2.2.2 clean re-installation theme luma.

I created a new module in app/code/ folder which is a magento2 custom widget

VendorName/MyNameSpace/etc/widget.xml

<?xml version="1.0" ?>
<widgets xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Widget:etc/widget.xsd">
<widget class="VendorName\MyNameSpace\Block\Widget\CustomWidget" id="customwidget">
<parameter name="custom_title" xsi:type="block" visible="true" required="true">
<label translate="true">TextArea</label>
<block class="VendorName\MyNameSpace\Block\Adminhtml\Widget\TextAreaField"/>
</parameter>
</widget>
</widgets>

In VendorName\MyNameSpace\Block\Adminhtml\Widget\TextAreaField.php, I created "Editor field" via \Magento\Framework\Data\Form\Element\Factory.

image
image

My Detail Step is below:

1. Go to Content -> Pages , select Home page -> edit
2. In Content Section, click the icon
step2

3. In the widget content: There are 2 options
3.a. Input text with wysiwyg off.
step3a

Click Insert Widget
It works!
step3a-worked
3.a.a If I double click on magento widget image and try to edit it with wysiwyg on
step3aa

Click Insert Widget. Check Magento-widget Snippet
step3aaa-snippet

You can see the content still aaa, it should be aaa now I will modify you with wysiwyg turn on.

3.b Input text with wysiwyg on.

Nothing happen , the icon magento widget doesnt show up, and there is no snippet code in the content.

In lib/web/mage/adminhtml/wysiwyg/widget.js I put a console.log() to get the result
widgetjs-modify

Try setup 3.b again , Inspect and check the output
widgetjs-output

If I copy the output and paste on content, it works. So I think there is some problem with js binding param.

Here is my source code for testing.

VendorName.zip

@magento-engcom-team magento-engcom-team added Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed Reproduced on 2.1.x The issue has been reproduced on latest 2.1 release Reproduced on 2.2.x The issue has been reproduced on latest 2.2 release Reproduced on 2.3.x The issue has been reproduced on latest 2.3 release and removed Progress: needs update labels Jan 30, 2018
@magento-engcom-team
Copy link
Contributor

@deagleka, thank you for your report.
We've acknowledged the issue and added to our backlog.

@nelero
Copy link

nelero commented Jul 16, 2018

Hi,
so, what's the solution ? seems this bug is openend for a while now :(

@molovo
Copy link
Contributor

molovo commented Dec 13, 2018

I just spotted this issue after opening #19742. Has there been any progress with finding a solution, or any workaround someone could recommend?

@ghost
Copy link

ghost commented Dec 13, 2018

Hello everyone, we close this ticket and postpone the discussion to the new one ->#19742

@ghost ghost closed this as completed Dec 13, 2018
molovo added a commit to molovo/magento2 that referenced this issue Jan 10, 2019
This PR is a potential fix for issues magento#19742 and magento#13409 (Thanks to @EduardTd for pointing me in the right direction).

I've tested this briefly in my own install and it appears to resolve the issue. Submitting this PR so that the issue can be tested fully.
@magento-engcom-team magento-engcom-team added the Fixed in 2.3.x The issue has been fixed in 2.3 release line label Apr 23, 2019
@magento-engcom-team
Copy link
Contributor

Hi @deagleka. Thank you for your report.
The issue has been fixed in #20174 by @molovo in 2.3-develop branch
Related commit(s):

The fix will be available with the upcoming 2.3.2 release.

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Fixed in 2.3.x The issue has been fixed in 2.3 release line Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development Reproduced on 2.1.x The issue has been reproduced on latest 2.1 release Reproduced on 2.2.x The issue has been reproduced on latest 2.2 release Reproduced on 2.3.x The issue has been reproduced on latest 2.3 release
Projects
None yet
Development

No branches or pull requests

4 participants