nebius/SWE-rebench-V2-PRs huggingface dataset:
Repository: JedWatson/react-select
Pull request #4373 (2021-01-13 07:57:16)

Fix value passed to onChange when clearing values
Related: https://github.com/JedWatson/react-select/issues/3632.

changeset-bot[bot]: ###  ⚠️  No Changeset found

Latest commit: f610933b3ff51db9c32cfc3608c17d3ed55e6a81

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. **If these changes should result in a version bump, you need to add a changeset.**

<details><summary>This PR includes no changesets</summary>

  When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

</details>

[Click here to learn what changesets are, and how to add one](https://github.com/changesets/changesets/blob/master/docs/adding-a-changeset.md).

[Click here if you're a maintainer who wants to add a changeset to this PR](https://github.com/Methuselah96/react-select/new/fix-on-change-bug?filename=.changeset/pink-cats-mate.md&value=---%0A%22react-select%22%3A%20patch%0A---%0A%0AFix%20value%20passed%20to%20onChange%20when%20clearing%20value%0A)


codesandbox[bot]: This pull request is automatically built and testable in [CodeSandbox](https://codesandbox.io).

  To see build info of the built libraries, click [here](https://ci.codesandbox.io/status/JedWatson/react-select/pr/4373/builds/91596) or the icon next to each commit SHA.

Latest deployment of this branch, based on commit f610933b3ff51db9c32cfc3608c17d3ed55e6a81:

|Sandbox| Source |
|--|--|
|[react-codesandboxer-example](https://codesandbox.io/s/react-codesandboxer-example-cpfnv)| Configuration |


Patch:
diff --git a/.changeset/pink-cats-mate.md b/.changeset/pink-cats-mate.md
new file mode 100644
index 00000000..f7f72787
--- /dev/null
+++ b/.changeset/pink-cats-mate.md
@@ -0,0 +1,5 @@
+---
+"react-select": patch
+---
+
+Fixed value passed to onChange when clearing value
diff --git a/packages/react-select/src/Select.js b/packages/react-select/src/Select.js
index 58285ace..bdec5b5b 100644
--- a/packages/react-select/src/Select.js
+++ b/packages/react-select/src/Select.js
@@ -706,8 +706,7 @@ export default class Select extends Component<Props, State> {
     this.focusInput();
   };
   clearValue = () => {
-    const { isMulti } = this.props;
-    this.onChange(isMulti ? [] : null, { action: 'clear' });
+    this.onChange(null, { action: 'clear' });
   };
   popValue = () => {
     const { selectValue } = this.state;


Test patch:
diff --git a/packages/react-select/src/__tests__/Select.test.js b/packages/react-select/src/__tests__/Select.test.js
index 84e7c5cf..6222482d 100644
--- a/packages/react-select/src/__tests__/Select.test.js
+++ b/packages/react-select/src/__tests__/Select.test.js
@@ -2305,7 +2305,7 @@ test('clear select by clicking on clear button > should not call onMenuOpen', ()
     container.querySelector('.react-select__clear-indicator'),
     { button: 0 }
   );
-  expect(onChangeSpy).toBeCalledWith([], {
+  expect(onChangeSpy).toBeCalledWith(null, {
     action: 'clear',
     name: BASIC_PROPS.name,
   });