Increasing/decreasing amount-control on a list changes the order of the list items

There is currently an issue where if you have a list with amount-control as your right element, and you change the amount for any of the list items, the order of the items below that item jumps.

Whilst this is being attended to, there is a temporary workaround you can perform:
adding an ORDER BY clause to your datasource's query to order your data by one of the columns.

This will resolve the issue and the order of your items will stay in tact.

Here you can find the behaviour before the fix:

CleanShot 2024-04-09 at 10.55.44

And here is the behavior after the fix:

CleanShot 2024-04-09 at 10.56.28

Below you can find the code samples for reference:

title: List with Amount Control (DD)
type: jig.list
icon: task-list
description: A list to display amount control
data: =@ctx.datasources.cleaning-services-dd

item:
  options:
    title: =@ctx.current.item.service
    subtitle: =@ctx.current.item.description
    rightElement:
      element: amount-control
      maximum: 5
      minimum: 1
      onChange:
        options:
          provider: DATA_PROVIDER_DYNAMIC
          entity: default/cleaning-services-dd
          data:
            id: =@ctx.current.item.id
            quantity: =@ctx.current.state.amount
          goBack: stay
          method: update
        type: action.execute-entity
      step: 1
      value: =$number(@ctx.current.item.quantity)
    style:
      isDisabled: =@ctx.current.state.amount = 5
  type: component.list-item
type: datasource.sqlite
options:
  provider: DATA_PROVIDER_DYNAMIC

  entities:
    - entity: default/cleaning-services-dd

  query: |
    SELECT id, '$.area', '$.description', '$.hourlyrate', '$.illustration', '$.image', '$.indoor', '$.onceoffrate', '$.service', '$.time' 
    FROM [default/cleaning-services-dd]
    ORDER by '$.service' ASC

Hope this helps. :crossed_fingers:

1 Like