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: incorrect display when value change from with label to without label #1029

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

xulingling0
Copy link
Contributor

fix: #1028

Copy link

vercel bot commented Feb 26, 2024

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

Name Status Preview Comments Updated (UTC)
select ✅ Ready (Inspect) Visit Preview 💬 Add feedback Feb 27, 2024 2:58am

Copy link

codecov bot commented Feb 26, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 99.78%. Comparing base (2535b87) to head (cb8a623).

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1029      +/-   ##
==========================================
- Coverage   99.78%   99.78%   -0.01%     
==========================================
  Files          38       38              
  Lines        1398     1395       -3     
  Branches      418      391      -27     
==========================================
- Hits         1395     1392       -3     
  Misses          3        3              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

src/hooks/useCache.ts Outdated Show resolved Hide resolved
// Fill label by cache
const patchedValues = labeledValues.map((item) => {
if (item.label === undefined) {
return {
...item,
label: prevValueCache.get(item.value)?.label,
label: prevOptionCache.get(item.value)?.label,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

此处不一定取label, 需结合
image

*/
export default (
labeledValues: LabelInValueType[],
valueOptions: Map<RawValueType, DefaultOptionType>,
): [LabelInValueType[], (val: RawValueType) => DefaultOptionType] => {
const cacheRef = React.useRef({
values: new Map<RawValueType, LabelInValueType>(),
Copy link
Member

Choose a reason for hiding this comment

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

这个不应该删掉,labelInValue 的时候需要 cache 住之前的 label。只有不设置 labelInValue 才应该清理掉。

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.

当value 没有 label 属性时,并且options 不包含 value 时,应当将 value 作为 label
3 participants