feat(module:cascader): support multiple selection#8903
feat(module:cascader): support multiple selection#8903HyperLife1119 merged 16 commits intoNG-ZORRO:masterfrom
Conversation
|
This preview will be available after the AzureCI is passed. |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #8903 +/- ##
==========================================
+ Coverage 91.87% 91.92% +0.04%
==========================================
Files 552 554 +2
Lines 19498 19702 +204
Branches 2895 2935 +40
==========================================
+ Hits 17914 18111 +197
+ Misses 1266 1265 -1
- Partials 318 326 +8 ☔ View full report in Codecov by Sentry. |
| [value]="inputValue!" | ||
| [autofocus]="autofocus" | ||
| [showInput]="true" | ||
| [showInput]="false" |
There was a problem hiding this comment.
这个特性在我们项目中使用较多,而且目前多选也没有支持传入nzShowSearch的参数 。 直接关掉的话,影响会比较大。
| protected get templateOutletContext(): NzSafeAny { | ||
| return { | ||
| $implicit: this.contentTemplateOutletContext, | ||
| ...this.contentTemplateOutletContext |
There was a problem hiding this comment.
传递 labelRenderContext
There was a problem hiding this comment.
不是很理解这里为什么在使用 $implicit 后,还需要将 contentTemplateOutletContext 展开传入 🤔
There was a problem hiding this comment.
当前 nzLabelRender template 的用法是具名 context,所以需要展开传递
当然我觉得也可以只用 $implicit,这里写法就会变成这样:
<ng-template #renderTpl let-data>
@for (label of data.labels; track label) {
@if (!$last) {
<span>{{ label }} /</span>
} @else {
<span>
{{ label }} (
<a href="javascript:;" (click)="handleAreaClick($event, label, selectedOptions[$index])">
{{ data.selectedOptions[$index].code }}
</a>
)
</span>
}
}
</ng-template>这将会是一个 Breaking change,需要在 release note 中说明。WDYT?
| @@ -583,18 +589,6 @@ describe('cascader', () => { | |||
| expect(values![0]).toBe('zhejiang'); | |||
| expect(values![1]).toBe('hangzhou'); | |||
| expect(values![2]).toBe('xihu'); | |||
There was a problem hiding this comment.
特性移除,参见 Breaking change
| protected get templateOutletContext(): NzSafeAny { | ||
| return { | ||
| $implicit: this.contentTemplateOutletContext, | ||
| ...this.contentTemplateOutletContext |
There was a problem hiding this comment.
不是很理解这里为什么在使用 $implicit 后,还需要将 contentTemplateOutletContext 展开传入 🤔
92fa24d to
66f8e6f
Compare

PR Checklist
Please check if your PR fulfills the following requirements:
PR Type
What kind of change does this PR introduce?
What is the current behavior?
Issue Number: close #6981 #8853
What is the new behavior?
Redesign the cascader component (which option list is now based on
NzTreeBase) and support multiple selectionDoes this PR introduce a breaking change?
BREAKING CHANGE
In the past, the cascader component kept a trick that if you wrote value with
NzCascaderOption[]type, it extracted value by mapping each item to its value property, for example:then the value of cascader would be
'ng-zorro-antd'.It's strange that the input and output values don't match when we haven't changed the values and it's hard to maintain. We expect that the value passed in should be the value in the list of options.
In v19, this trick is removed and if you're already using this trick in your code, please consider the add a
mapfunction to pass the actual value.旧版本中,在表单中为 Cascader 组件赋值为
NzCascaderOption[]类型时,Cascader 组件会根据提供的nzValueProperty映射成实际的值并写入,例如:此时 Cascader 组件输出的值将为
'ng-zorro-antd'。这就导致输入与输出的值不一致,可能存在潜在的数据问题。在 v19 中,我们将移除该特性,如果您已经在代码中运用了该特性,请考虑增加一个
map方法将其映射到实际的值。Other information