[MGNLUI-7071] jcrMultivalueField: deleting item shows mgnl:removed when orderHandler is used Created: 22/Mar/22  Updated: 20/Jul/22  Resolved: 05/May/22

Status: Closed
Project: Magnolia UI
Component/s: None
Affects Version/s: 6.2.17
Fix Version/s: 6.2.19, 6.3.0

Type: Bug Priority: Neutral
Reporter: Jonathan Ayala Assignee: Adam Siska
Resolution: Fixed Votes: 0
Labels: None
Σ Remaining Estimate: Not Specified Remaining Estimate: Not Specified
Σ Time Spent: Not Specified Time Spent: Not Specified
Σ Original Estimate: Not Specified Original Estimate: Not Specified

Issue Links:
causality
Sub-Tasks:
Key
Summary
Type
Status
Assignee
MGNLUI-7105 Prepare fallback (workaround) solution Sub-task Completed Adam Siska  
MGNLUI-7110 Code review and preint QA Sub-task Completed Roman Kovařík  
MGNLUI-7112 Docu Sub-task Completed Adam Siska  
MGNLUI-7113 Final QA Sub-task Completed Antonín Juran  
MGNLUI-7128 Integrate fix and doc update Sub-task Completed Adam Siska  
MGNLUI-7129 Forward port to cloud Sub-task Completed Adam Siska  
MGNLUI-7130 Final QA on cloud Sub-task Closed Sang Ngo Huu  
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: Nucleus Quality Maintenance
Sprint: Nucleus 9
Story Points: 8
Team: Nucleus

 Description   

Steps to reproduce

  1. Make use of the following field in any dialog:
    field:
      $type: jcrMultiValueField
      orderHandler:
        class: info.magnolia.ui.editor.MultiFormDefinition$OrderHandlerDefinition$Noop
      field:
        $type: pageLinkField
        label: label.empty
        textInputAllowed: true
  1. Open the dialog, add two elements and save.
  2. Edit the saved item by removing the first element and save
  3. Open the dialog again

Expected results

The removed item doesn't appear anymore

Actual results

There's a mgnl:removed item

Workaround

Removing the orderHandler configuration makes the issue disappear



 Comments   
Comment by Adam Siska [ 11/Apr/22 ]

Discovery:

  • first at all, this is not among documented options: https://docs.magnolia-cms.com/product-docs/6.2/Modules/List-of-modules/Content-Editor-module/Multi-JCR-block.html
  • but on the other hand, setting noop order handler in multi field definition removes possibility of reordering items in ui
  • for the record: this works well as long as items are nodes (there are not even there by the time any applyOrder is called)
  • problems comes with JcrMultiValue fields, both MultiFormView::write nor MultiFormDefinition.OrderHandlerDefinition.Noop#Noop are aware of jcr properties
  • in other words jcr-specific code from MultiValuePropertyOrderHandler#applyOrder needs to be triggered even in this case (to filter out deleted properties from list)

Solution suggestion:

Comment by Rabie Hayoun [ 11/Apr/22 ]

why Noop returning an mgnl:removed item?

why the default order handler does not?

Comment by Roman Kovařík [ 11/Apr/22 ]

Discovery Completed:

  1. mgnl:removed is created by the value provider (we need a tmp mock item to work with after clicking the delete button)
  2. The default order handler removes these items which is a side effect (after changing the handler to Noop, mgnl:removed stay after save)

 

  • As mgnl:removed is created the the value provider, it should be also responsible for cleaning it up
  • if that's not possible, we can apply the workaround suggested by asiska knowing that:
    • we can't use any other order handler (this should be prevented e.g. by throwing a definition app error, including MultiValuePropertyOrderHandler)
    • we always trigger the orderhandler, even though we don't want to order the items (mgnl:removed is cleaned up as order handler side effect)
Generated at Mon Feb 12 09:42:52 CET 2024 using Jira 9.4.2#940002-sha1:46d1a51de284217efdcb32434eab47a99af2938b.