Skip to content

fix(core): support stickyHeaderTemplate as an XML element template - #11722

Merged
NathanWalker merged 1 commit into
NativeScript:mainfrom
liuy97:fix/list-view-sticky-header-template
Dec 2, 2026
Merged

NathanWalker merged 1 commit into
NativeScript:mainfrom
liuy97:fix/list-view-sticky-header-template

Conversation

@liuy97

@liuy97 liuy97 commented Dec 2, 2026

Copy link
Copy Markdown
Contributor

PR Checklist

What is the current behavior?

When stickyHeaderTemplate is declared using the XML element form:

<ListView items="{{ sections }}" sectioned="true" stickyHeader="true">
    <ListView.stickyHeaderTemplate>
        <Label text="{{ title }}" />
    </ListView.stickyHeaderTemplate>
</ListView>

the builder does not treat stickyHeaderTemplate as a template, so the header content is not compiled into a template function. On Android, only string templates were handled, so headers fell back to a default Section N label. Header creation was also implemented separately on iOS and Android, with different parsing and fallback behavior.

What is the new behavior?

  • stickyHeaderTemplate is registered in Builder.knownTemplates, so <ListView.stickyHeaderTemplate> compiles into a template function, just like itemTemplate.
  • Sticky header view creation now goes through one shared ListViewBase._resolveStickyHeaderView(section). It accepts both string and function templates and is used on both iOS and Android. If the template is missing or fails, the header falls back to a Section N label. This replaces the duplicated per-platform parse/fallback code and removes the unused iOS _headerTemplateCache.
  • Adds a sectioned-listview example page to apps/ui.
  • Adds automated tests in apps/automated:
    • test_stickyHeaderTemplate_xml_element_form_is_a_template
    • test_stickyHeader_function_template_binds_section

Closes #11697.

Register `stickyHeaderTemplate` in `Builder.knownTemplates` so the
`<ListView.stickyHeaderTemplate>` element form is compiled into a template
function.

Also adds a sectioned ListView example to apps/ui and automated tests
covering the XML element form and function templates binding section data.

Closes NativeScript#11697
@github-actions

github-actions Bot commented Dec 2, 2026 •

Copy link
Copy Markdown
Contributor

✅ All contributors on this pull request have satisfied the NativeScript CLA.

@liuy97

liuy97 commented Dec 2, 2026

Copy link
Copy Markdown
Contributor Author

I have read the CLA and I hereby sign the CLA

@github-actions

github-actions Bot commented Dec 2, 2026

Copy link
Copy Markdown
Contributor

Thanks @liuy97 — your signature on this PR satisfies the CLA check, and you'll be recorded on the cla-signatures branch after this PR merges. The CLA check will re-run.

@NathanWalker NathanWalker added this to the 9.2 milestone Dec 2, 2026
@NathanWalker
NathanWalker merged commit 327e227 into NativeScript:main Dec 2, 2026
7 of 8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ListView: support <ListView.stickyHeaderTemplate> element

2 participants