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: select onChangeWithObject in multiple when optinList empty and u… #2139

Merged
merged 3 commits into from Mar 29, 2024

Conversation

pointhalo
Copy link
Collaborator

@pointhalo pointhalo commented Mar 25, 2024

…pdate other key in selections, render not update

中文模板 / 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 #

Changelog

🇨🇳 Chinese

  • Fix: 修复 Select 多选开启 onChangWithObject 且 value 受控,当前value 并不存在于 optionList 中,更新了 value中的其他属性后渲染未重新执行的问题

🇺🇸 English

  • Fix: Fixed the problem that when onChangWithObject is turned on for Select multi-selection and value is controlled, the current value does not exist in the optionList, and the rendering is not re-executed after updating other properties in the value.

Checklist

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

Other

  • Skip Changelog

Additional information

复现 Demo

const UpdateOtherKeyNotInList = () => {
  const [v, setV] = useState([
    {
      label: 'AA-Label',
      value: 'AA',
      otherProps: 'AA-OtherProps',
    },
  ]);
  useEffect(() => {
    setTimeout(
      () =>
        setV([
          {
            label: 'AA-Label-2',
            value: 'AA',
            otherProps: 'AA-OtherProps-2',
          },
        ]),
      2000,
    );
  }, []);
  const renderSelectedItem = (optionNode) => {
    const { label, otherProps } = optionNode;
    const content = (
      <div>
        {label}-{otherProps}
      </div>
    );
    return {
      isRenderInTag: false,
      content,
    };
  };
  return (
    <Select
      value={v}
      onChange={setV}
      filter
      multiple
      renderSelectedItem={renderSelectedItem}
      onChangeWithObject
      style={{ width: 320 }}
    />
  );
};

…pdate other key in selections, render not update
Copy link

codesandbox-ci bot commented Mar 25, 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 de15bfc:

Sandbox Source
pr-story Configuration

@codecov-commenter
Copy link

codecov-commenter commented Mar 25, 2024

Codecov Report

Attention: Patch coverage is 83.33333% with 1 lines in your changes are missing coverage. Please review.

Project coverage is 88.18%. Comparing base (21f02ca) to head (ea4718c).
Report is 1 commits behind head on main.

❗ Current head ea4718c differs from pull request most recent head 64447ac. Consider uploading reports for the commit 64447ac to get more accurate results

Files Patch % Lines
packages/semi-foundation/select/foundation.ts 83.33% 1 Missing ⚠️

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

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #2139   +/-   ##
=======================================
  Coverage   88.18%   88.18%           
=======================================
  Files         440      440           
  Lines       25932    25937    +5     
  Branches     6600     6602    +2     
=======================================
+ Hits        22867    22872    +5     
  Misses       3065     3065           

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

Copy link

cypress bot commented Mar 25, 2024

Passing run #2373 ↗︎

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

Details:

Merge 64447ac into 2650b4f...
Project: semi-design Commit: ea4718cc6a ℹ️
Status: Passed Duration: 10:17 💡
Started: Mar 25, 2024 8:08 AM Ended: Mar 25, 2024 8:18 AM

Review all test suite changes for PR #2139 ↗︎

@pointhalo pointhalo merged commit 36bf2c5 into main Mar 29, 2024
4 of 6 checks passed
@pointhalo pointhalo deleted the fix-selectOnchangeWithObejctUpdateOtherkey branch March 29, 2024 09:23
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

2 participants