Titanium JIRA Archive
Alloy (ALOY)

[ALOY-1684] Calling sort for a collection does not call the dataFunction as of backbone 1.1.2 and above

GitHub Issuen/a
TypeBug
PriorityNone
StatusClosed
ResolutionFixed
Resolution Date2019-06-19T14:21:46.000+0000
Affected Version/sAlloy 1.13.9
Fix Version/sCLI Release 7.1.0, Alloy 1.14.0
ComponentsBuiltins, Models
Labelsn/a
ReporterEwan Harris
AssigneeEwan Harris
Created2019-04-30T13:26:25.000+0000
Updated2019-06-19T14:21:46.000+0000

Description

Description

https://github.com/appcelerator-developer-relations/appc-sample-databinding is the sample used to demo this When calling .sort() on a collection the dataFunction should be called, however when using backbone 1.1.2 or above, this is not called. This is because (as noted in the [migration guide](https://docs.appcelerator.com/platform/latest/#!/guide/Alloy_Backbone_Migration-section-src-43290758_AlloyBackboneMigration-EventAPIs)), sort no longer triggers a reset event but a sort event, and we don't listen for a sort event [at all](https://github.com/appcelerator/alloy/blob/master/Alloy/common/constants.js#L69), to fix this we need to add "sort" to that array (probably conditionally when using 1.1.2 or greater), but this will potentially introduce an unexpected behaviour change for users

Steps to reproduce

1. Download https://github.com/appcelerator-developer-relations/appc-sample-databinding 2. Build the app to any platform 3. Click on "orange" 4. Click the "+" button 5. Go back to the main view 6. Click "Sort: name" 7. Select "Amount" 8. Now add "backbone": "1.1.2" to your app/config.json, clean the project and repeat steps 2-7

Expected

When changing the sort type to amount, orange should go to the top of the list

Actual

When using backbone 1.1.2, the list is not sorted when changing the sort type

Comments

  1. Ewan Harris 2019-04-30

    cc [~bhouse] [~topener], I ran into this while performing the backbone 1.4.0 upgrade. Do you think this is something we can fix safely, or would the potential behaviour change be problematic for users?
  2. Ewan Harris 2019-06-05

    Included in the PR for the backbone 1.4.0 inclusion https://github.com/appcelerator/alloy/pull/929/commits/22ac957bbfd6e696a10cbb8a10726951d2254061
  3. Samir Mohammed 2019-06-19

    *Closing ticket*, Fix verified in CLI Version 7.1.0-master.21 tested using the test case mentioned in the description. When changing the sort type to amount, orange was able to go to the top of the list *Test Environment*
       SDK: 8.0.2.GA
       Operating System
         Name                        = Mac OS X
         Version                     = 10.14.4
         Architecture                = 64bit
         CPUs                      = 8
         Memory                      = 16.0GB
       Node.js
         Node.js Version             = 10.13.0
         npm Version                 = 6.4.1
       Appcelerator CLI
         Installer                   = 4.2.14-3
         Core Package                = 7.1.0-master.21
       Titanium CLI
         CLI Version                 = 5.2.1
         node-appc Version           = 0.2.49
       

JSON Source