Title: fix(listview): correct item template resolution in sectioned ListView by VeinDevTtv · Pull Request #11184 · NativeScript/NativeScript · GitHub
Open Graph Title: fix(listview): correct item template resolution in sectioned ListView by VeinDevTtv · Pull Request #11184 · NativeScript/NativeScript
X Title: fix(listview): correct item template resolution in sectioned ListView by VeinDevTtv · Pull Request #11184 · NativeScript/NativeScript
Description: PR Checklist The PR title follows our guidelines: https://github.com/NativeScript/NativeScript/blob/master/tools/notes/CONTRIBUTING.md#commit-messages. There is an issue for the bug/feature this PR is for. To avoid wasting your time, it's best to open a suggestion issue first and wait for approval before working on it. You have signed the CLA. All existing tests are passing: https://github.com/NativeScript/NativeScript/blob/master/tools/notes/DevelopmentWorkflow.md#running-unit-tests-application. Tests for the changes are included - https://github.com/NativeScript/NativeScript/blob/master/tools/notes/WritingUnitTests.md. What is the current behavior? When using a sectioned ListView with multiple item templates and an itemTemplateSelector, the wrong template is returned for items. _getItemTemplate(index) calls _getDataItem(index) which reads directly from this.items[index]. In sectioned mode, this.items is an array of section objects (e.g. { title, items }), so indexing it by row number returns a section object instead of the actual row data item. The itemTemplateSelector then receives the wrong data and resolves the wrong template key, causing incorrect cell types to be recycled and rendered. On iOS, _prepareCell contained a broken absoluteIndex workaround that summed up items across sections and fed that offset back into the same flat _getItemTemplate — which still hits this.items[absoluteIndex] on the sectioned top-level array, returning another section object. What is the new behavior? A new method _getItemTemplateInSection(section, index) is added to ListViewBase. It uses _getDataItemInSection to correctly fetch the row item from within its section, and _getItemsInSection to pass the section's own items array to the itemTemplateSelector — matching the same contract that _prepareItemInSection uses for binding contexts. All call sites that select a template for a sectioned row are updated to use this method: iOS: tableViewCellForRowAtIndexPath, tableViewHeightForRowAtIndexPath, and _prepareCell (replacing the broken absoluteIndex workaround). Android: getItemViewType and _createItemView. Fixes #11133.
Open Graph Description: PR Checklist The PR title follows our guidelines: https://github.com/NativeScript/NativeScript/blob/master/tools/notes/CONTRIBUTING.md#commit-messages. There is an issue for the bug/feature this...
X Description: PR Checklist The PR title follows our guidelines: https://github.com/NativeScript/NativeScript/blob/master/tools/notes/CONTRIBUTING.md#commit-messages. There is an issue for the bug/feature this...
Opengraph URL: https://github.com/NativeScript/NativeScript/pull/11184
X: @github
Domain: Github.com
| route-pattern | /:user_id/:repository/pull/:id/files(.:format) |
| route-controller | pull_requests |
| route-action | files |
| fetch-nonce | v2:b35db090-1f3f-0fe6-bbba-7eb12a392652 |
| current-catalog-service-hash | ae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b |
| request-id | BC0C:25D1F8:C49544:118D167:6A6386CD |
| html-safe-nonce | cc12682c937456e5242f02a649bf706d2f9223030d68ae42552d9719d0ef47a1 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCQzBDOjI1RDFGODpDNDk1NDQ6MTE4RDE2Nzo2QTYzODZDRCIsInZpc2l0b3JfaWQiOiI2ODM5NzgwMjIxNDY4NzcyMDQ1IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | e83e072f6b328eb6e720a4a7b36dec5e739d3984b1bc646d8931976b8fa4f8fc |
| hovercard-subject-tag | pull_request:3551242093 |
| github-keyboard-shortcuts | repository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/NativeScript/NativeScript/pull/11184/files |
| twitter:image | https://avatars.githubusercontent.com/u/142545968?s=400&v=4 |
| twitter:card | summary_large_image |
| og:image | https://avatars.githubusercontent.com/u/142545968?s=400&v=4 |
| og:image:alt | PR Checklist The PR title follows our guidelines: https://github.com/NativeScript/NativeScript/blob/master/tools/notes/CONTRIBUTING.md#commit-messages. There is an issue for the bug/feature this... |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | e4fb64aef87da454ec25b158147f7f5f14aef29216e5ca1612c2e48faa599d1f |
| turbo-cache-control | no-preview |
| diff-view | unified |
| go-import | github.com/NativeScript/NativeScript git https://github.com/NativeScript/NativeScript.git |
| octolytics-dimension-user_id | 7392261 |
| octolytics-dimension-user_login | NativeScript |
| octolytics-dimension-repository_id | 31492490 |
| octolytics-dimension-repository_nwo | NativeScript/NativeScript |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 31492490 |
| octolytics-dimension-repository_network_root_nwo | NativeScript/NativeScript |
| turbo-body-classes | logged-out env-production page-responsive full-width |
| disable-turbo | true |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | e839936ba5faffb9c836dda1cf4729d50c88a32e |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width