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

feat: support titleRender #447

Merged
merged 5 commits into from
Dec 4, 2023
Merged

Conversation

huangkairan
Copy link
Contributor

Copy link

vercel bot commented Nov 15, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
tree-select ❌ Failed (Inspect) Nov 29, 2023 6:50am

src/TreeSelect.tsx Outdated Show resolved Hide resolved
Copy link

codecov bot commented Nov 15, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (e85d617) 100.00% compared to head (5e51a89) 100.00%.
Report is 1 commits behind head on master.

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.
📢 Have feedback on the report? Share it here.

@@ -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;
Copy link
Member

Choose a reason for hiding this comment

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

这个看起来会把 labelInValue 给误改掉,有 labelInValue 的时候,没有 label 才能改这个。

Copy link
Contributor Author

@huangkairan huangkairan Nov 17, 2023

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);
}

Copy link
Member

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

@MadCcc MadCcc merged commit 5f5be87 into react-component:master Dec 4, 2023
9 of 10 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.

3 participants