[MGNLUI-6672] Cannot disable automatic sorting in comboBox/linkField Created: 26/Apr/21  Updated: 13/Aug/21  Resolved: 10/Aug/21

Status: Closed
Project: Magnolia UI
Component/s: None
Affects Version/s: 6.2.10
Fix Version/s: 6.2.12

Type: Bug Priority: Neutral
Reporter: Viet Nguyen Assignee: Roman Kovařík
Resolution: Fixed Votes: 13
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Attachments: Java Source File SourceSortedCheckBoxGroupFieldDefinition.java     Java Source File SourceSortedCheckBoxGroupFieldFactory.java    
Issue Links:
Relates
causality
caused by MGNLUI-6483 linkField: Setting path manually in d... Closed
caused by MGNLUI-5994 Deprecate sortable in favor of sortBy... Closed
documentation
to be documented by MGNLUI-6820 DOC: New 'sort' property in 'OptionLi... Closed
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
Testcase included:
Yes
Release notes required:
Yes
Documentation update required:
Yes
Date of First Response:
Epic Link: UI framework implementation
Sprint: UI FW 34
Story Points: 3

 Description   

Steps to reproduce

  1. Configure a comboBoxField using optionListDatasource like below:
        selectOne:
          $type: comboBoxField
          defaultValue: internal
          datasource:
            $type: optionListDatasource
            sortable: false
            options:
              - name: disabled
                value: disabled
                label: disabled
              - name: auto
                value: auto
                label: auto
              - name: off
                value: off
                label: off
    

.. Logs, screenshots, gifs...

Expected results

  • The combo box entries show up in the defined order (disabled -> auto -> off)

.. Justify non-trivial expectations with a link to a doc or a relevant discussion.

Actual results

  • Since Magnolia 6.2.7, entries show up in alphabetical order
  • This seems to have been introduced with 6.2.7 / MGNLUI-5994

Workaround

  • No.

Development notes

  • Documentation update required.


 Comments   
Comment by Simon Tourville [ 18/May/21 ]

Same issue here.

Comment by Jeffrey van der Heide [ 19/May/21 ]

In the meantime, here's the workaround for my checkbox group fields, similar workarounds should work for other FieldDefinitions

SourceSortedCheckBoxGroupFieldDefinition.java

SourceSortedCheckBoxGroupFieldFactory.java

 

Comment by Viet Nguyen [ 19/May/21 ]

Thank you jvanderheide for your provided workaround. We will consider fixing this soon so that the benefits could wide spreading to other customers.

Comment by Jeffrey van der Heide [ 19/May/21 ]

The underlying issue stems from info.magnolia.ui.contentapp.CaptionFilteringDataProviderWrapper#fetch.
Which sorts regardless of provided preferences, I'm assuming this is because the same data provider logic is used in the subapp views.

I think getting the sorting mechanism from the Datasource would be the best way forward, this would allow custom sorting logic for custom datasources and defaults could fallback to a default sorting mechanic (that should still be able to be set from a definition, to sort like intended AND allow just to return the order of the data is). 

Comment by Roman Kovařík [ 01/Jun/21 ]

Hi jvanderheide,

The underlying issue stems from info.magnolia.ui.contentapp.CaptionFilteringDataProviderWrapper#fetch.

You're right, I can even see that this was fixed in a snapshot:
https://git.magnolia-cms.com/projects/PLATFORM/repos/ui/commits/d958d6a4919e51ce21b0341805da2ca8a836e0b4
but then reverted due to MGNLUI-6587 https://git.magnolia-cms.com/projects/PLATFORM/repos/ui/pull-requests/1743/overview.
We should reapply and fix the cause of MGNLUI-6587.

Roman

Comment by Christopher Chard [ 08/Jul/21 ]

Hi rkovarik,
any chance this can make it into 6.2.11 ?

Many complaints from editors coming in saying that the comboboxes are confusing and unintuitive :/

Thanks!
Chris

Comment by Simon Tourville [ 08/Jul/21 ]

+1

Comment by Roman Kovařík [ 08/Jul/21 ]

Hi,

Can't promise but it's pretty close to the top of the backlog :crossed_fingers:

Roman

Comment by Roman Kovařík [ 04/Aug/21 ]

For release notes:
Items in select fields were always sorted since 6.2.7. This now happens only if sorting is configured explicitly, e.g.:

form:
  properties:
    optionSorted:
      $type: comboBoxField
      datasource:  
        $type: optionListDatasource
        sort: true
        options:
          - name: b
            label: b
          - name: a
            label: a
     jcrSorted:
      $type: comboBoxField
      datasource: 
        $type: jcrDatasource
        workspace: website
        allowedNodeTypes:
          - mgnl:page
        describeByProperty: title
        sortBy:
          title: ASCENDING
Comment by Christopher Chard [ 10/Aug/21 ]

Awesome, thank you!

Comment by Roman Kovařík [ 13/Aug/21 ]

For documentation:

https://docs.magnolia-cms.com/product-docs/6.2/Apps/App-configuration/Data-source-definition/Option-list-data-source.html#_list_of_properties

sort optionaldefault is false
When true, the list of options is sorted.
Generated at Mon Feb 12 09:38:51 CET 2024 using Jira 9.4.2#940002-sha1:46d1a51de284217efdcb32434eab47a99af2938b.