[MGNLUI-5736] Complex fields with jcrChildNodeProvider persists empty node when not touched Created: 16/Mar/20  Updated: 07/Nov/22  Resolved: 07/Nov/22

Status: Closed
Project: Magnolia UI
Component/s: None
Affects Version/s: 6.2.18
Fix Version/s: 6.3, 6.2.27

Type: Bug Priority: Neutral
Reporter: Adam Siska Assignee: Adam Siska
Resolution: Fixed Votes: 3
Labels: None
Σ Remaining Estimate: Not Specified Remaining Estimate: Not Specified
Σ Time Spent: 1.25d Time Spent: 1.25d
Σ Original Estimate: Not Specified Original Estimate: Not Specified

Issue Links:
Problem/Incident
causes MGNLUI-7022 i18n for switchableField doesn't do f... Closed
Sub-Tasks:
Key
Summary
Type
Status
Assignee
MGNLUI-7582 Implementation Sub-task Completed Adam Siska  
MGNLUI-7583 Code review Sub-task Completed Roman Kovařík  
MGNLUI-7584 Preintegration QA Sub-task Completed Quach Hao Thien  
MGNLUI-7585 QA Sub-task Closed Antonín Juran  
MGNLUI-7591 DOCu: new "removeIfEmpty" property in... Sub-task Completed Adam Siska  
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
Documentation update required:
Yes
Date of First Response:
Epic Link: jcrChildNodeProvider creates nodes for unselected subforms
Sprint: Nucleus 22
Story Points: 3
Team: Nucleus

 Description   

Steps to reproduce:
1) in Resources app modify /contacts/dialogs/rename.yaml

form:
  properties:
    jcrName:
      label: New name
      $type: textField
    upload:
      class: info.magnolia.ui.editor.UploadViewDefinition
      itemProvider:
        $type: jcrChildNodeProvider
    composite:
      $type: compositeField
      itemProvider:
        $type: jcrChildNodeProvider
      properties:
        city:
          label: city
          $type: textField
        country:
          label: country
          $type: textField
          

2) invoke dialog on node and save dialog without touching fields

Expectation (and old-fw behaviour): nothing happens

Actual behaviour: empty subnodes are created within the node for fields



 Comments   
Comment by Roman Kovařík [ 10/Oct/22 ]

Discovery:

Sketched solution:

  • track nonpersisted nodes in JcrDatasource via JcrNodeWrapper#addNode
  • upon JcrDatasource#commit iterate these nodes and remove all with only system properties or no subnodes

Possible problem: Given a complex field with e.g. only mgnl:lastModified field, this one would bw removed.

  • should we make this configurable with a jcrChildProvider#canRemoveEmptyNodes?
  • jcrChildProvider would set e.g. mgnl:canRemoveIfEmpty property which would be checked before the removal
  • mgnl:canRemoveIfEmpty might be true by default to fix the reported issues but could be disabled via YAML for this use case
Generated at Mon Feb 12 09:29:32 CET 2024 using Jira 9.4.2#940002-sha1:46d1a51de284217efdcb32434eab47a99af2938b.