Uploaded image for project: 'Titanium SDK/CLI'
  1. Titanium SDK/CLI
  2. TIMOB-28533

Android: ListView scrollToItem always uses first section

    Details

    • Story Points:
      3

      Description

      The current ListView.scrollToItem always scrolls to the first section if there are multiple.

      I've tested 10.1.0 after https://github.com/appcelerator/titanium_mobile/pull/12762 was merged with this code:

      const win = Ti.UI.createWindow();
      const animation = { animated: true };
      const toggle_animation = Ti.UI.createButton({ bottom: 20, title: `animated: ${animation.animated}` });
       
      function createSection(sectionId, rows) {
      	const section = Ti.UI.createListSection({
      		headerTitle: `Section ${sectionId}`
      	});
      	const items = [];
       
      	for (let i = 0; i < rows; i++) {
      		items.push({
      			properties: {
      				title: `${sectionId} Row #${i}`,
      				searchableText: `Row #${i}`
      			}
      		});
      	}
      	section.items = items;
       
      	return section;
      }
      const listView = Ti.UI.createListView({ sections: [ createSection(0, 40),createSection(1, 40),createSection(2, 40) ] });
       
      toggle_animation.addEventListener('click', e => {
      	animation.animated = !animation.animated;
      	toggle_animation.title = `animated: ${animation.animated}`;
      });
       
      setInterval(_ => {
      	const i = Math.floor(Math.random() * listView.sections[0].itemCount);
      	listView.scrollToItem(1, i, animation);  // use second section
      	console.log(`scrollToItem: ${i}`);
      }, 2000);
       
      win.add([ listView, toggle_animation ]);
      win.open();
      

      (almost the same as in the ticket but with 3 sections and scrollToItem(1, random)

      It should scroll to the 2nd section, so rows with "1 - row..." should be the targets. But it is always going to "0 - row ..." items.

      SDK: 10.1.0 (compiled 9/8/2021)
      Android 11, Pixel 4 (device)

        Attachments

          Activity

            People

            • Assignee:
              gmathews Gary Mathews
              Reporter:
              michael Michael Gangolf
              Reviewer:
              Joshua Quick
            • Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Backbone Issue Sync

                • Backbone Issue Sync is enabled for your project, but we do not have any synchronization info for this issue.

                  Git Integration