-
Notifications
You must be signed in to change notification settings - Fork 194
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
feat: support titleRender #447
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #447 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 16 16
Lines 514 518 +4
Branches 147 140 -7
=========================================
+ Hits 514 518 +4 ☔ View full report in Codecov by Sentry. |
src/TreeSelect.tsx
Outdated
@@ -438,9 +440,10 @@ const TreeSelect = React.forwardRef<BaseSelectRef, TreeSelectProps>((props, ref) | |||
// Back fill with origin label | |||
const labeledValues = values.map(val => { | |||
const targetItem = rawLabeledValues.find(item => item.value === val); | |||
const label = treeTitleRender ? treeTitleRender(targetItem) : targetItem?.label; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这个看起来会把 labelInValue
给误改掉,有 labelInValue
的时候,没有 label
才能改这个。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这个看起来会把
labelInValue
给误改掉,有labelInValue
的时候,没有label
才能改这个。
是我理解的这样吗:
let label = targetItem?.label;
// Ensure that when labelInValue is true, if label is undefined, it remains undefined.
if (treeTitleRender && (!labelInValue || (labelInValue && !label))) {
label = treeTitleRender(targetItem);
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
对,不过这个可以优化一下。labelInValue && .label ~= undefined 就用自己的 label,反之再过一遍 titleRender
ref: ant-design/ant-design#45884