merkle-open / aem-generic-multifield

Generic Multifield component dialog extension for AEM
MIT License
15 stars 6 forks source link

Granite multifield is not working properly with genericmultifield in the same dialog #35

Closed RaoulBivolaru closed 7 months ago

RaoulBivolaru commented 4 years ago

I'm having an issue when I try to use genericmultifield and granite/ui/components/coral/foundation/form/multifield in the same dialog.

When I edit an item from genericmultifield and if I have a granite multifield in the same dialog, the fields from granite multifield gets updated with a new value for the name;

Below you can see the field name before updating an item: before-update

And here you can see it after editing an item after-update

The field path is updated from: ./pages/item0/./linkUrl to ./pages/item0/./pages/item0/./linkUrl

My code:

<genericmultifield
    jcr:primaryType="nt:unstructured"
    sling:resourceType="namics/genericmultifield"
    fieldLabel="Teaser Items"
    itemDialog="/apps/website/components/content/standardteaser/teaseritemdialog"
    itemStorageNode="items"
    itemNameProperty="textarea"
    name="./items"/>
<teaserpages
    jcr:primaryType="nt:unstructured"
    sling:resourceType="granite/ui/components/coral/foundation/form/multifield"
    composite="{Boolean}true"
    fieldLabel="Teaser Pages">
  <field
    jcr:primaryType="nt:unstructured"
    sling:resourceType="granite/ui/components/coral/foundation/container"
    name="./pages">
    <items
        jcr:primaryType="nt:unstructured">
        <linkurl
            jcr:primaryType="nt:unstructured"
            sling:resourceType="granite/ui/components/coral/foundation/form/pathbrowser"
            name="./linkUrl"
            rootPath="/content"/>
    </items>
  </field>
</teaserpages>

I'm using AEM version 6.5.4.

mkiti commented 4 years ago

Are you using the latest generic multifield version 3.1.0?

RaoulBivolaru commented 4 years ago

Yes

RaoulBivolaru commented 4 years ago

From what I can see, the issue is coming from this line: https://github.com/namics/aem-generic-multifield/blob/6.5/master/src/main/resources/SLING-INF/apps/namics/genericmultifield/clientlibs/js/GenericMultifieldDialogHandler.js#L223

I tested without calling _restoreDialogData and everything is working fine. What is the purpose of this method?

mkiti commented 4 years ago

When opening a new dialog, the parent dialog is closed and placed on a stack. When the newly opened dialog is closed again, this method retrieves the parent dialog from the stack and displays it. I will try to reproduce the error when I have time.

I will try to reproduce the error when I have time.

Maybe there's a conflict with the "items" name.

Can you specify something else in the generic multifield for itemStorageNode and name. e.g. itemStorageNode="teasers", name="./teasers".

Or alternatively, for the multifield instead of <items> use <teaseritems>:

<teaserpages
    jcr:primaryType="nt:unstructured"
    sling:resourceType="granite/ui/components/coral/foundation/form/multifield"
    composite="{Boolean}true
    fieldLabel="Teaser Pages">
  <field
    jcr:primaryType="nt:unstructured"
    sling:resourceType="granite/ui/components/coral/foundation/container"
    name="./pages">
    <teaseritems
        jcr:primaryType="nt:unstructured">
        <left
            jcr:primaryType="nt:unstructured"
            sling:resourceType="granite/ui/components/coral/foundation/form/pathbrowser"
            name="./linkUrl"
            rootPath="/content"/>
    </teaseritems>
  </field>
</teaserpages>
RaoulBivolaru commented 4 years ago

Tested both solutions and I still have the same problem.

I think _restoreDialogData is redundant. https://github.com/namics/aem-generic-multifield/blob/6.5/master/src/main/resources/SLING-INF/apps/namics/genericmultifield/clientlibs/js/GenericMultifieldDialogHandler.js#L190 is taking care of closing the current dialog and opening parent dialog.

mkiti commented 4 years ago

No, it's not redundant. If the method is not called, the data previously entered in the parent dialog disappears as soon as the multifield dialog is closed.

ridzi-tech commented 4 months ago

Hey guys i am facing a similiar issue, if i modify anything on genericmultifield it removes data of granitemultifield anyone facing it?