Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-23734] Windows: section updateItemAt updates wrong item

GitHub Issuen/a
TypeBug
PriorityCritical
StatusClosed
ResolutionFixed
Resolution Date2016-08-12T01:55:39.000+0000
Affected Version/sRelease 5.4.0
Fix Version/sRelease 6.0.0
ComponentsWindows
LabelslistView, qe-5.4.0, windowsphone
ReporterZakhar Zhuravlev
AssigneeGary Mathews
Created2016-08-04T09:39:49.000+0000
Updated2016-08-17T16:13:54.000+0000

Description

affect version - 5_4_X 5.4.0.v20160802165655 *index.js:*
function onUpdate() {
	$.section.updateItemAt(1, {info: {text: 'update'}});
}

$.section.appendItems([
	{info: {text: 'title 1'}},
	{info: {text: 'title 2'}},
	{info: {text: 'title 3'}}
]);
$.win.open();
*index.xml:*
<Alloy>
    <Window id="win" backgroundColor='black'>
		<ListView id="list" defaultItemTemplate="template">

            <Templates>
                <ItemTemplate name="template">
                    <Label bindId="info" id="title" />
                </ItemTemplate>
            </Templates>

            <ListSection id='section' />
        </ListView>
        
        <Button width='100dp' height='50dp' bottom="50dp" backgroundColor='red' onClick='onUpdate' />
	</Window>
</Alloy>
in 5_4_X 5.4.0.v20160802165655 updates 2nd elem instead of 1st. in 5.3.0 working fine

Comments

  1. Hans Knöchel 2016-08-05

    Reopening as a 5.4.0 regression for now, [~gmathews] already looks into it. Thanks!
  2. Gary Mathews 2016-08-08

    I cannot reproduce the issue, this test case seems to work fine *TEST CASE #1*
       var win = Ti.UI.createWindow({ backgroundColor: 'blue' }),
           section = Ti.UI.createListSection({
               headerTitle: 'Letters',
               items: [
                   { properties: { title: '0: A' } },
                   { properties: { title: '1: A' } },
                   { properties: { title: '2: C' } },
                   { properties: { title: '3: D' } }
               ]
           }),
           listView = Ti.UI.createListView({ sections: [section] });
       
       listView.addEventListener('click', function (e) {
           section.updateItemAt(1, { properties: { title: '1: B' } });
       });
       
       win.add(listView);
       win.open();
       
    *Please note that the item index starts at 0, the first item in the list is at index 0 and not index 1.*
  3. Zakhar Zhuravlev 2016-08-08

    Of course, I know that array index starts from 0. Your example works for me!! But you don't use .xml file. Try MY example! MY EXAMPLE DOESN'T WORK CORRECTLY!!!!
  4. Harry Bryant 2016-08-08

    I can confirm that this is a valid bug. with [~gmathews]'s test code, the correct item is updated (set to 1, second item in the list). But with [~zozo4kin]'s test code: *updateItemAt 0:* Second item is updated. *updateItemAt 1:* Third item is updated. *updateItemAt 2:* Runtime Error: Exception Unknown. Seems that the indexing is being read incorrectly with Alloy Projects. Tested on: Windows 10 Pro Windows Phone 10.0 (Microsoft Lumia 640 LTE) Appc Studio: 4.7.0.201607250649 Ti SDK: 5.4.0.v20160804185318 Appc NPM: 4.2.7 Appc Core: 5.4.0-40 Node: v4.4.4 *Reopening Ticket.*
  5. Gary Mathews 2016-08-08

    Ah, the problem was the inclusion of a headerTitle. Apologies. *TEST CASE #2*
       var win = Ti.UI.createWindow({ backgroundColor: 'blue' }),
           section = Ti.UI.createListSection({
               items: [
                   { properties: { title: '0: A' } },
                   { properties: { title: '1: A' } },
                   { properties: { title: '2: C' } },
                   { properties: { title: '3: D' } }
               ]
           }),
           listView = Ti.UI.createListView({ sections: [section] });
        
       listView.addEventListener('click', function (e) {
           section.updateItemAt(1, { properties: { title: '1: B' } });
       });
        
       win.add(listView);
       win.open();
       
    master: https://github.com/appcelerator/titanium_mobile_windows/pull/808 5_4_X: https://github.com/appcelerator/titanium_mobile_windows/pull/809
  6. Ewan Harris 2016-08-09

    Verified using: Windows 10 Pro Appc core: 5.4.0-40 Appc NPM: 4.2.7 Ti SDK: 5.4.0.v20160809033140 Lumia 930: 10.0 Lumia 520: 8.1 When calling section.updateItemAt on a section with no header the correct item is now updated Closing ticket
  7. Zakhar Zhuravlev 2016-08-10

    IT IS NOT WORKING FOR 0 index! try update item at 0 index and ypu will get exception: message: "invalid vector subscript" native_stack: ["JSExportClass::CallNamedFunction"]
  8. Ewan Harris 2016-08-10

    [~zozo4kin] Thanks. I'll reopen this ticket. Windows 10 Pro Appc core: 5.4.0-40 Appc NPM: 4.2.7 Ti SDK: 5.4.0.v20160809033140
       var win = Ti.UI.createWindow({ backgroundColor: 'blue' }),
           section = Ti.UI.createListSection({
               items: [
                   { properties: { title: '0: A' } },
                   { properties: { title: '1: A' } },
                   { properties: { title: '2: C' } },
                   { properties: { title: '3: D' } }
               ]
           }),
           listView = Ti.UI.createListView({ sections: [section] });
        
       listView.addEventListener('click', function (e) {
           section.updateItemAt(0, { properties: { title: '1: B' } });
       });
        
       win.add(listView);
       win.open();
       
  9. Gary Mathews 2016-08-10

    master: https://github.com/appcelerator/titanium_mobile_windows/pull/813
  10. Zakhar Zhuravlev 2016-08-11

    Why 6.0.0 ? =((( It's very critical bug, I'm waiting for it. It was working in 5.3.0 and 5.3.1....
  11. Hans Knöchel 2016-08-11

    [~zozo4kin] We just released 5.4.0.GA today and the ticket was just raised this week. After it is merged, it needs to go through our quality engineering to be tested in detail. The next possible release therefore is 6.0.0, but you can still apply the PR manually to your SDK and patch it. Please see our guides on how to do that, thanks!
  12. Ewan Harris 2016-08-17

    Verified using: Windows 10 Pro Appc core: 6.0.0-26 Appc NPM: 4.2.8-5 Ti SDK: 6.0.0.v20160817065403 updateItemAt now updates the correct item and no longer errors on index 0 when not using headerTitle. Closing ticket

JSON Source