[MGNLUI-6905] Complex fields (new UI) creates empty contentNode at JCR for each language Created: 07/Oct/21  Updated: 02/Dec/21  Resolved: 02/Dec/21

Status: Closed
Project: Magnolia UI
Component/s: None
Affects Version/s: 6.2.11
Fix Version/s: 6.2.14

Type: Bug Priority: Neutral
Reporter: Carlos Cantalapiedra Assignee: Adam Siska
Resolution: Fixed Votes: 4
Labels: maintenance, ui-team-support
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Attachments: PNG File jcr.png    
Issue Links:
Problem/Incident
Template:
Acceptance criteria:
Empty
Task DoD:
[X]* Doc/release notes changes? Comment present?
[X]* Downstream builds green?
[X]* Solution information and context easily available?
[X]* Tests
[X]* FixVersion filled and not yet released
[ ]  Architecture Decision Record (ADR)
Bug DoR:
[X]* Steps to reproduce, expected, and actual results filled
[X]* Affected version filled
Release notes required:
Yes
Date of First Response:
Sprint: UI Maintenance 1, UI Maintenance 2
Story Points: 5

 Description   

Steps to reproduce

  1.  Create a multiValue which has 18n enable, like this:
    myDialog.yaml
    label: Events List
    form:
      properties:
        events:
          $type: jcrMultiField
          i18n: true
          label: Events
          itemProvider:
            $type: jcrChildNodeProvider
          field:
            $type: compositeField
            properties:
              title:
                label: title
                $type: textField
              date:
                label: date
                $type: dateField
  1.  Create the component
  2. Save data only in English
  3. Check at JCR that a mgnl:contentNode (empty) has been created for all available languages

Expected results

Only those nodes of language to which was switched are created. Node for default language is created every time.

Actual results

For each language, a mgnl:contentNode is created, even if the user didn't create (add) any field at the dialog for that language

Workaround

Use the old UI dialog definition (for this case, if you use this you can check the behavior):

my_old_dialog_definition.yaml
form:
  tabs:
    - name: tabText
      label: Multivalue composite
      fields:
        - name: events
          fieldType: multiValue
          i18n: true
          label: Events
          transformerClass: info.magnolia.ui.form.field.transformer.multi.MultiValueSubChildrenNodePropertiesTransformer
          field:
            name: compositeField
            fieldType: composite
            transformerClass: info.magnolia.ui.form.field.transformer.composite.NoOpCompositeTransformer
            fields:
              - name: title
                fieldType: text
                label: Title
              - name: date
                fieldType: date
                label: Date

actions:
  commit:
    class: info.magnolia.ui.admincentral.dialog.action.SaveDialogActionDefinition
  cancel:
    class: info.magnolia.ui.admincentral.dialog.action.CancelDialogActionDefinition

Development notes

On Magnolia 5.7, only those fields which had been added to a language were saved, otherwise they weren't created (please check the attachments)

This behavior affects on first place to performance for users which have lots of languages enabled on a site and, on second place, if working with nodes/delivery api. On that second case, if you perform a REST call to get the nodes for that component you may get (following the Events example) that there are 10 events in 10 different languages when really only English has events and the other 9 are empty nodes that were created because this bug.



 Comments   
Comment by Eduard Lehel Reichenberger [ 08/Nov/21 ]

Hello,

Is there a workaround for this issue until this is fixed in future versions? It's not possible to create content at the moment with this issue since other languages will have empty content.

Comment by Roman Kovařík [ 30/Nov/21 ]

Hey Eduard,

no workaround I can think of unfortunately but the issue is just being integrated to the latest snapshot and should be released with Magnolia 6.2.14.
 

Regards
Roman

Comment by Adam Siska [ 01/Dec/21 ]

reopened: switchablefield related problem, https://git.magnolia-cms.com/projects/PLATFORM/repos/ui/pull-requests/1952/overview

Comment by Roman Kovařík [ 02/Dec/21 ]

What was done:

Complex field are not created eagerly anymore for all locales but later when the user switches the language.

 

Generated at Mon Feb 12 09:41:11 CET 2024 using Jira 9.4.2#940002-sha1:46d1a51de284217efdcb32434eab47a99af2938b.