Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(list): specify template ref context on input to match instantiation #7756

Merged

Conversation

pburgmer
Copy link
Contributor

@pburgmer pburgmer commented Dec 7, 2022

PR Checklist

Please check if your PR fulfills the following requirements:

PR Type

What kind of change does this PR introduce?

[x] Bugfix
[ ] Feature
[ ] Code style update (formatting, local variables)
[ ] Refactoring (no functional changes, no api changes)
[ ] Build related changes
[ ] CI related changes
[ ] Documentation content changes
[ ] Application (the showcase website) / infrastructure changes
[ ] Other... Please describe:

What is the current behavior?

Currently input nzRenderItem on NzList component is defined as TemplateRef<void> but it is instantiated with a context.

It works in current version to pass in a template, which relies on a provided context. Unfortunately template refs and their context are not type checked by Angular. So you can pass in a TemplateRef with context even if a TemplateRef without context is expected by the input. And ng-zorro can provide a context during the instantiation even if the TemplateRef is specified without context.

Issue Number: N/A

What is the new behavior?

Input nzRenderItem on NzList component is now defined as TemplateRef<{ $implicit: NzSafeAny, index: number}>, the same context type as the template is providing.

Does this PR introduce a breaking change?

[ ] Yes
[x] No

Other information

@zorro-bot
Copy link

zorro-bot bot commented Dec 7, 2022

This preview will be available after the AzureCI is passed.

@codecov
Copy link

codecov bot commented Dec 7, 2022

Codecov Report

Merging #7756 (6ead4b7) into master (3771512) will decrease coverage by 0.01%.
The diff coverage is 100.00%.

❗ Current head 6ead4b7 differs from pull request most recent head f140369. Consider uploading reports for the commit f140369 to get more accurate results

@@            Coverage Diff             @@
##           master    #7756      +/-   ##
==========================================
- Coverage   92.03%   92.02%   -0.02%     
==========================================
  Files         502      502              
  Lines       16768    16768              
  Branches     2638     2638              
==========================================
- Hits        15432    15430       -2     
- Misses       1069     1070       +1     
- Partials      267      268       +1     
Impacted Files Coverage Δ
components/list/list.component.ts 100.00% <100.00%> (ø)
components/tabs/tab-nav-bar.component.ts 87.23% <0.00%> (-0.71%) ⬇️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

* input was specified as TemplateRef<void> but usage of template provides a context
* providing a context was/is possible because Angular does not check the template reference and the provided context to match
* consuming the context and pass in a template ref with context is also possible because a template ref is TemplateRef<any> per default
@pburgmer pburgmer force-pushed the fix-list-item-renderer-template-context branch from 5e952ef to f140369 Compare December 7, 2022 13:09
Copy link
Member

@simplejason simplejason left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@simplejason simplejason merged commit 4eb32fd into NG-ZORRO:master Dec 11, 2022
chenc041 pushed a commit to chenc041/ng-zorro-antd that referenced this pull request Dec 14, 2022
…NG-ZORRO#7756)

* input was specified as TemplateRef<void> but usage of template provides a context
* providing a context was/is possible because Angular does not check the template reference and the provided context to match
* consuming the context and pass in a template ref with context is also possible because a template ref is TemplateRef<any> per default
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants