Skip to content

Widget field depends with type block KO #13316

Closed
@Selven99

Description

@Selven99

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>
  1. 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!

Metadata

Metadata

Assignees

No one assigned

    Labels

    Component: CmsComponent: WidgetFixed in 2.4.xThe issue has been fixed in 2.4-develop branchIssue: Clear DescriptionGate 2 Passed. Manual verification of the issue description passedIssue: ConfirmedGate 3 Passed. Manual verification of the issue completed. Issue is confirmedIssue: Format is validGate 1 Passed. Automatic verification of issue format passedIssue: Ready for WorkGate 4. Acknowledged. Issue is added to backlog and ready for developmentPriority: P2A defect with this priority could have functionality issues which are not to expectations.Progress: doneReproduced on 2.1.xThe issue has been reproduced on latest 2.1 releaseReproduced on 2.2.xThe issue has been reproduced on latest 2.2 releaseReproduced on 2.3.xThe issue has been reproduced on latest 2.3 releaseReproduced on 2.4.xThe issue has been reproduced on latest 2.4-develop branchSeverity: S2Major restrictions or short-term circumventions are required until a fix is available.Triage: Dev.ExperienceIssue related to Developer Experience and needs help with Triage to Confirm or Reject it

    Type

    No type

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions