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 parameter depends does not work on specified block #6868

Closed LordHansolo closed 4 years ago

LordHansolo commented 8 years ago

Preconditions

  1. Magento 2.1.1

    Steps to reproduce

  2. Create Module adding Custom Widget
  3. Add Parameter like `
           <depends>
               <parameter name="enable_url" value="1" />
               <parameter name="target_url" value="1" />
           </depends>
           <block class="Magento\Catalog\Block\Adminhtml\Category\Widget\Chooser">
               <data>
                   <item name="button" xsi:type="array">
                       <item name="open" xsi:type="string" translate="true">Select Category...</item>
                   </item>
               </data>
           </block>
       </parameter>`

    parameter_depends It is important to use block class="Magento\Catalog\Block\Adminhtml\Category\Widget\Chooser" or block class="Magento\Catalog\Block\Adminhtml\Product\Widget\Chooser".

  4. Set any custom depends.
  5. Go to admin panel. Add your widget. In widget options change parameter that our parameter depends on.

    Expected result

Our Parameter disappears, if conditions set on depends are not met.

Actual result

Parameter is visible anyway.

biolauri commented 7 years ago

It's also an issue in Magento 2.1.2. And, in my opinion, it is not important which block class you use, as this is a general issue with all parameters of xsi:type="block" depending on another parameter.

In #5443, you find detailed info of the expected/actual for the problem (display:none; is set on the wrong html element). I can confirm that these are the same for this one! Maybe, this is a duplicate of #5443 (but the steps to reproduce are a bit different).

magento-engcom-team commented 7 years ago

@LordHansolo, thank you for your report. We've created internal ticket(s) MAGETWO-82054 to track progress on the issue.

henk-hypershop commented 7 years ago

What will be the expected fix timeframe? It is quite confusing that all depend labels are still shown.

VincentMarmiesse commented 6 years ago

Hello, Any news on this issue?

maartenwolfsen commented 5 years ago

In my case, the problem was that the selected rowElement was the child of the rowElement that was supposed to be hidden. I added the following piece of code to fix this to lib/web/mage/adminhtml/form.js line 567:

if (rowElement.className === 'admin__field-control control') { rowElement = target.up(2); }

I am currently looking for a better solution.

m2-assistant[bot] commented 5 years ago

Hi @sergey-solo. 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:


OvalMedia commented 5 years ago

For the impatient here is a fix: https://magento.stackexchange.com/questions/176091/magento-2-depends-is-not-working-in-widget-xml. Make sure you consider the first comment as the require-config.js is placed in the wrong directory. I can confirm it works fine on 2.2.9.

koenner01 commented 5 years ago

I can confirm this issue is still present in 2.3.3.

Fix from @OvalMedia works but I really don't like copying a gigantic javascript and appending 3 lines. This is not very future (= maintainable) proof.

Sankarant commented 4 years ago

Found this issue present in Magento 2.3.1. Please share the patch for this issue. Fix from @OvalMedia works great.

hostep commented 4 years ago

Here's a solution which seems to work in our case, it's strongly based on the stackexchange proposal but drops the original PrototypeJS implementation and uses jQuery all the way now: https://github.com/magento/magento2/pull/30570

magento-engcom-team commented 4 years ago

Hi @LordHansolo. 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.

DmitryFurs commented 4 years ago

@magento-engcom-team @sidolov @ihor-sviziev the corresponding pull request is merged, but the fix does not cover all possible cases. 2 additional cases are described in the comments to the pull request https://github.com/magento/magento2/pull/30570