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.56k stars 9.32k forks source link

Widget field depends with type block KO #13316

Closed Selven99 closed 4 years ago

Selven99 commented 6 years ago

Preconditions

  1. Magento 2.4-develop
  2. PHP 7, MySQL: ANY

Steps to reproduce

  1. Create a custom widget with widget.xml file
  2. Create a select option chooser
    <parameter name="test_select" xsi:type="select" visible="true" required="true" sort_order="10">
    <label translate="true">Select</label>
    <options>
        <option name="val_1" value="val_1" selected="true">
            <label translate="true">Value 1</label>
        </option>
        <option name="val_2" value="val_2">
            <label translate="true">Value 2</label>
        </option>
    </options>
    </parameter>
  3. Create a CMS block Chooser that needs the second option selected
    <parameter name="block_2_id" xsi:type="block" visible="true" required="true" sort_order="30">
    <label translate="true">Block 2</label>
    <depends>
        <parameter name="test_select" value="val_2" />
    </depends>
    <block class="Magento\Cms\Block\Adminhtml\Block\Widget\Chooser">
        <data>
            <item name="button" xsi:type="array">
                <item name="open" xsi:type="string" translate="true">Select Block...</item>
            </item>
        </data>
    </block>
    </parameter>

Expected result

  1. When I select the Val 1, CMS Chooser is not visible
  2. When I select the Val 2, CMS Chooser is visible

Actual result

  1. When I select the Val 1, CMS Chooser is visible
  2. When I select the Val 2, CMS Chooser is visible

I checked: /lib/web/mage/adminhtml/form.js In trackChange function, I add log after getting target row: console.log(idTo); (line 450 ~)

It tries to get item "options_fieldset61f7a8d3475b5def75f144b49f5d69a9_block_2_id" but this selector doesn't exists! If I try $('options_fieldset61f7a8d3475b5def75f144b49f5d69a9_block_2_id') I get NULL.

Generated HTML for CMS chooser is:

<div class="admin__field field field-options_fieldset61f7a8d3475b5def75f144b49f5d69a9_block_2_id  with-addon required _required with-note"
     data-ui-id="widget-instance-edit-tab-properties-fieldset-element-form-field-options-fieldset61f7a8d3475b5def75f144b49f5d69a9-block-2-id">
    <label class="label admin__field-label" for="options_fieldset61f7a8d3475b5def75f144b49f5d69a9_block_2_id"
           data-ui-id="widget-instance-edit-tab-properties-fieldset-element-label-parameters-block-2-id-label"><span>Block 2</span></label>
    <div class="admin__field-control control">
        <div class="admin__field">
            <div class="control-value"></div>
            <label class="widget-option-label"
                   id="options_fieldset61f7a8d3475b5def75f144b49f5d69a9_block_2_ided82f16acfe32d39acd5b9f1d94c5fc2label">Onepage
                Success</label>
            <div id="options_fieldset61f7a8d3475b5def75f144b49f5d69a9_block_2_ided82f16acfe32d39acd5b9f1d94c5fc2advice-container"
                 class="hidden"></div>

        </div>
        <div class="note admin__field-note" id="options_fieldset61f7a8d3475b5def75f144b49f5d69a9_block_2_id-note"></div>
    </div>
</div>
<div class="admin__field field field-chooseroptions_fieldset61f7a8d3475b5def75f144b49f5d69a9_block_2_id  with-addon"
     data-ui-id="widget-instance-edit-tab-properties-fieldset-element-form-field-chooseroptions-fieldset61f7a8d3475b5def75f144b49f5d69a9-block-2-id">
    <label class="label admin__field-label" for="chooseroptions_fieldset61f7a8d3475b5def75f144b49f5d69a9_block_2_id"
           data-ui-id="widget-instance-edit-tab-properties-fieldset-element-note-label"><span></span></label>
    <div class="admin__field-control control">
        <div class="admin__field">
            <div id="chooseroptions_fieldset61f7a8d3475b5def75f144b49f5d69a9_block_2_id"
                 class="control-value admin__field-value"></div>
            <input id="options_fieldset61f7a8d3475b5def75f144b49f5d69a9_block_2_ided82f16acfe32d39acd5b9f1d94c5fc2value"
                   name="parameters[block_2_id]"
                   data-ui-id="widget-instance-edit-tab-properties-element-hidden-parameters-block-2-id" value="2"
                   class="widget-option required-entry" type="hidden">
            <button id="options_fieldset61f7a8d3475b5def75f144b49f5d69a9_block_2_ided82f16acfe32d39acd5b9f1d94c5fc2control"
                    title="Select Block..." type="button" class="action-default scalable btn-chooser"
                    onclick="options_fieldset61f7a8d3475b5def75f144b49f5d69a9_block_2_ided82f16acfe32d39acd5b9f1d94c5fc2.choose()"
                    data-ui-id="widget-button-9">
                <span>Select Block...</span>
            </button>
        </div>
    </div>
</div>

Thanks for your help! It seems to be a bug with widget chooser (like CMS block) and depends!

Selven99 commented 6 years ago

Hello,

Would anyone have information on this problem?

Thanks, :)

magento-engcom-team commented 6 years ago

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

jburel-ca commented 5 years ago

Hi, Do you have any update about this issue?

maartenwolfsen commented 5 years ago

Any update on this issue?

m2-assistant[bot] commented 4 years ago

Hi @engcom-Alfa. Thank you for working on this issue. Looks like this issue is already verified and confirmed. But if you want to validate it one more time, please, go though the following instruction:


engcom-Alfa commented 4 years ago

The issue is still reproducible on the fresh 2.4-develop instance

Actual Result: When I select the Val 1, CMS Chooser is visible When I select the Val 2, CMS Chooser is visible screen

magento-engcom-team commented 4 years ago

@engcom-Alfa Thank you for verifying the issue.

Unfortunately, not enough information was provided to acknowledge ticket. Please consider adding the following:

Once all required information is added, please add label "Issue: Confirmed" again. Thanks!

m2-assistant[bot] commented 4 years ago

Hi @engcom-Alfa. 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:

magento-engcom-team commented 4 years ago

:white_check_mark: Confirmed by @engcom-Alfa Thank you for verifying the issue. Based on the provided information internal tickets MC-30368 were created

Issue Available: @engcom-Alfa, You will be automatically unassigned. Contributors/Maintainers can claim this issue to continue. To reclaim and continue work, reassign the ticket to yourself.

magento-engcom-team commented 4 years ago

Hi @Selven99. Thank you for your report. The issue has been fixed in magento/magento2#30570 by @hostep in 2.4-develop branch Related commit(s):

The fix will be available with the upcoming 2.4.2 release.