Skip to content

Magento_Ui/js/modal/modal-component cannot be used inside dynamic rows #38226

Open
@ioweb-gr

Description

@ioweb-gr

Preconditions and environment

  • 2.3.2

Steps to reproduce

  1. Create a new UI form using dynamic rows.
  2. Inside the dynamic rows add a button and a modal ui component, that will be triggered when the button is clicked.
  3. Open the UI form and add a new row in the ui component
  4. Check console and find a javascript error that visible() is not a function.

Expected result

Modal is opened properly

Actual result

Javascript error

Additional information

The problem is coming from Magento_Ui/js/modal/modal-component which doesn't have a visible property set.
Therefore when the dynamic rows component tries to set visibility, the error will come up

Sample code to replicate

<fieldset name="products" sortOrder="20">
        <settings>
            <label translate="true">Products</label>
        </settings>
        <dynamicRows name="dynamic_rows" sortOrder="70">
            <settings>
                <addButtonLabel translate="true">Add Product</addButtonLabel>
                <additionalClasses>
                    <class name="admin__field-wide">true</class>
                </additionalClasses>
                <componentType>dynamicRows</componentType>
            </settings>
            <container name="record" component="Magento_Ui/js/dynamic-rows/record">
                <argument name="data" xsi:type="array">
                    <item name="config" xsi:type="array">
                        <item name="isTemplate" xsi:type="boolean">true</item>
                        <item name="is_collection" xsi:type="boolean">true</item>
                        <item name="componentType" xsi:type="string">container</item>
                    </item>
                </argument>
                <field name="quantity" formElement="input">
                    <argument name="data" xsi:type="array">
                        <item name="config" xsi:type="array">
                            <item name="fit" xsi:type="boolean">false</item>
                        </item>
                    </argument>
                    <settings>
                        <validation>
                            <rule name="required-entry" xsi:type="boolean">true</rule>
                        </validation>
                        <dataType>number</dataType>
                        <label>Quantity</label>
                    </settings>
                </field>
                <button name="products" component="Magento_Ui/js/form/components/button">
                    <argument name="data" xsi:type="array">
                        <item name="config" xsi:type="array">
                            <item name="label" xsi:type="string" translate="true">
                                Select Products
                            </item>
                            <item name="title" xsi:type="string" translate="true">
                                Products
                            </item>
                            <item name="displayAsLink" xsi:type="boolean">true</item>
                            <item name="labelVisible" xsi:type="boolean">true</item>
                            <item name="template" xsi:type="string">ui/form/components/button/container</item>
                            <item name="actions" xsi:type="array">
                                <item name="0" xsi:type="array">
                                    <item name="targetName" xsi:type="string">${$.parentName}.products_modal</item>
                                    <item name="actionName" xsi:type="string">openModal</item>
                                </item>
                            </item>
                        </item>
                    </argument>
                </button>
                <modal name="products_modal">
                    <argument name="data" xsi:type="array">
                        <item name="config" xsi:type="array">
                            <item name="provider" xsi:type="string">io_quickorder_form.io_quickorder_form_data_source</item>
                            <item name="onCancel" xsi:type="string">actionDone</item>
                            <item name="options" xsi:type="array">
                                <item name="title" xsi:type="string">All Products</item>
                                <item name="buttons" xsi:type="array">
                                    <item name="0" xsi:type="array">
                                        <item name="text" xsi:type="string">Selected</item>
                                        <item name="class" xsi:type="string">action-primary</item>
                                        <item name="actions" xsi:type="array">
                                            <item name="0" xsi:type="array">
                                                <item name="targetName" xsi:type="string">index = product_listing</item>
                                                <item name="actionName" xsi:type="string">save</item>
                                            </item>
                                            <item name="1" xsi:type="string">closeModal</item>
                                        </item>
                                    </item>
                                </item>
                            </item>
                        </item>
                    </argument>
                    <insertListing name="product_listing">
                        <settings>
                            <dataLinks>
                                <exports>false</exports>
                                <imports>true</imports>
                            </dataLinks>
                            <autoRender>true</autoRender>
                            <selectionsProvider>product_listing.product_listing.columns.ids</selectionsProvider>
                            <dataScope>product_listing</dataScope>
                            <ns>product_listing</ns>
                        </settings>
                    </insertListing>
                </modal>

            </container>
        </dynamicRows>
    </fieldset>

Release note

No response

Triage and priority

  • Severity: S0 - Affects critical data or functionality and leaves users without workaround.
  • Severity: S1 - Affects critical data or functionality and forces users to employ a workaround.
  • Severity: S2 - Affects non-critical data or functionality and forces users to employ a workaround.
  • Severity: S3 - Affects non-critical data or functionality and does not force users to employ a workaround.
  • Severity: S4 - Affects aesthetics, professional look and feel, “quality” or “usability”.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Area: Admin UIComponent: UiIssue: ConfirmedGate 3 Passed. Manual verification of the issue completed. Issue is confirmedPriority: P2A defect with this priority could have functionality issues which are not to expectations.Progress: ready for devReported on 2.3.2Indicates original Magento version for the Issue report.Reproduced on 2.4.xThe issue has been reproduced on latest 2.4-develop branchTriage: Dev.ExperienceIssue related to Developer Experience and needs help with Triage to Confirm or Reject it

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions