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/cascader rendertrigger #2051

Merged
merged 4 commits into from
Jan 31, 2024
Merged

Fix/cascader rendertrigger #2051

merged 4 commits into from
Jan 31, 2024

Conversation

YyumeiZhang
Copy link
Collaborator

@YyumeiZhang YyumeiZhang commented Jan 29, 2024

中文模板 / Chinese Template

What kind of change does this PR introduce? (check at least one)

  • Bugfix
  • Feature
  • Code style update
  • Refactor
  • Test Case
  • TypeScript definition update
  • Document improve
  • CI/CD improve
  • Branch sync
  • Other, please describe:

PR description

Fixes # 本问题由于 #1999 的修改导致,为提高在大数据 treeData 的 Cascader 的性能,key 的生成规则发生改变。对于 如下 treeData

const treeData = [
        {
            label: '浙江省',
            value: 'zhejiang',
            children: [
                {
                    label: '杭州市',
                    value: 'hangzhou',
                    children: [
                        {
                            label: '西湖区',
                            value: 'xihu',
                        },
                        {
                            label: '萧山区',
                            value: 'xiaoshan',
                        }
                    ],
                }
            ],
        }
    ];

原来:和 TreeData 的中的位置有关,比如[浙江, 杭州, 西湖],key 为 0-0-0;
#1999 修改后: 将 value 用特殊字符连接,对于[浙江, 杭州, 西湖], key 为 zhejiang_SEMI_CASCADER_SPLIT_hangzhou
_SEMI_CASCADER_SPLIT_xihu;

修改后能够快速通过 key 找到 value,在受控时提升组件性能。

但是在根据原来 key 和 pos 关联的性质,原来的代码中有将 keyEntities中的 key 的值作为 triggerRender 中的 value 参数
image
,由于 key 的生成规则,变化,因此不再适合通过 keyEntities中的 key 的值作为 triggerRender 中的 value ,而是应该将真正的 pos 给到value。

因此本 PR 中的修改为:

  1. 保证triggerRender 使用显示正确:在 keyEntities 中增加 pos,用于保存 data 在 treeData 中的位置,将 pos 作为 triggerRender 的 value 值
  2. 保证 triggerRender 中删除正确:在 triggerRender 的删除回调 onRemove 的具体执行函数中,增加从 pos 找 key的逻辑

Changelog

🇨🇳 Chinese

  • Fix: 修复 Cascader 在 keyEntities 中的 key 生成规则变化后,triggerRender 的参数中的value 参数和原来不一致问题(影响范围 2.51.0~2.51.3)

🇺🇸 English

  • Fix: Fixed the problem that after Cascader's key generation rules in keyEntities changed, the value parameter in triggerRender's parameters was inconsistent with the original one (Affected Scope 2.51.0~2.51.3)

Checklist

  • Test or no need
  • Document or no need
  • Changelog or no need

Other

  • Skip Changelog

Additional information

Sorry, something went wrong.

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
…composition in keyEntities change
Copy link

codesandbox-ci bot commented Jan 29, 2024

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit 3c76bd5:

Sandbox Source
pr-story Configuration
Semi Design: Simple Story Configuration

Copy link

cypress bot commented Jan 29, 2024

Passing run #2223 ↗︎

0 219 10 0 Flakiness 0
⚠️ You've recorded test results over your free plan limit.
Upgrade your plan to view test results.

Details:

Merge 3c76bd5 into 1fe3733...
Project: semi-design Commit: 3e4694f67b ℹ️
Status: Passed Duration: 08:17 💡
Started: Jan 29, 2024 6:32 AM Ended: Jan 29, 2024 6:41 AM

Review all test suite changes for PR #2051 ↗︎

@codecov-commenter
Copy link

codecov-commenter commented Jan 29, 2024

Codecov Report

Attention: 14 lines in your changes are missing coverage. Please review.

Comparison is base (8f0f15d) 87.37% compared to head (3e4694f) 87.42%.
Report is 1 commits behind head on main.

❗ Current head 3e4694f differs from pull request most recent head 3c76bd5. Consider uploading reports for the commit 3c76bd5 to get more accurate results

Files Patch % Lines
packages/semi-foundation/cascader/util.ts 11.11% 8 Missing ⚠️
packages/semi-foundation/cascader/foundation.ts 57.14% 3 Missing ⚠️
packages/semi-ui/cascader/index.tsx 76.92% 3 Missing ⚠️

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2051      +/-   ##
==========================================
+ Coverage   87.37%   87.42%   +0.05%     
==========================================
  Files         437      437              
  Lines       25655    25664       +9     
  Branches     6501     6502       +1     
==========================================
+ Hits        22417    22438      +21     
+ Misses       3238     3226      -12     

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

@YyumeiZhang YyumeiZhang merged commit 6091967 into main Jan 31, 2024
9 checks passed
@YyumeiZhang YyumeiZhang deleted the fix/cascader-rendertrigger branch January 31, 2024 12:11
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.

None yet

3 participants