Skip to content

Commit

Permalink
Merge branch 'master' into react-19-types
Browse files Browse the repository at this point in the history
  • Loading branch information
Methuselah96 authored Nov 9, 2024
2 parents ed73fc2 + 28251dc commit fa51804
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 8 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ The Select control for [React](https://reactjs.org). Initially built for use in
See [react-select.com](https://www.react-select.com) for live demos and comprehensive docs.

`react-select` is funded by [Thinkmill](https://www.thinkmill.com.au) and [Atlassian](https://atlaskit.atlassian.com).
We are an open source project that is continously supported by the community.
We are an open source project that is continuously supported by the community.

React Select helps you develop powerful select components that _just work_ out of the box, without stopping you from customising the parts that are important to you.

Expand Down
12 changes: 12 additions & 0 deletions packages/react-select/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
# react-select

## 5.8.2

### Patch Changes

- [`781284a9`](https://github.com/JedWatson/react-select/commit/781284a97059b80c07eb77bc871540fe99304e8f) [#5771](https://github.com/JedWatson/react-select/pull/5771) Thanks [@tu4mo](https://github.com/tu4mo)! - Fix for calling non-cancellable scroll events

## 5.8.1

### Patch Changes

- [`dd740ced`](https://github.com/JedWatson/react-select/commit/dd740cedb29c810a89da4445d4864cd7e63d3aaf) [#5960](https://github.com/JedWatson/react-select/pull/5960) Thanks [@leonaves](https://github.com/leonaves)! - No longer send pop-value action when multi-select is empty. This correctly resolves typings with that event, where removedValue cannot be undefined.

## 5.8.0

### Minor Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/react-select/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "react-select",
"version": "5.8.0",
"version": "5.8.2",
"description": "A Select control built with and for ReactJS",
"main": "dist/react-select.cjs.js",
"module": "dist/react-select.esm.js",
Expand Down
10 changes: 6 additions & 4 deletions packages/react-select/src/Select.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1097,10 +1097,12 @@ export default class Select<
newValueArray[0] || null
);

this.onChange(newValue, {
action: 'pop-value',
removedValue: lastSelectedValue,
});
if (lastSelectedValue) {
this.onChange(newValue, {
action: 'pop-value',
removedValue: lastSelectedValue,
});
}
};

// ==============================
Expand Down
21 changes: 20 additions & 1 deletion packages/react-select/src/__tests__/Select.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1906,6 +1906,7 @@ test('should call onChange with an array on hitting backspace when backspaceRemo
isClearable
isMulti
onChange={onChangeSpy}
value={[OPTIONS[0]]}
/>
);
fireEvent.keyDown(container.querySelector('.react-select__control')!, {
Expand All @@ -1915,10 +1916,28 @@ test('should call onChange with an array on hitting backspace when backspaceRemo
expect(onChangeSpy).toHaveBeenCalledWith([], {
action: 'pop-value',
name: 'test-input-name',
removedValue: undefined,
removedValue: OPTIONS[0],
});
});

test('should call not call onChange on hitting backspace when backspaceRemovesValue is true and isMulti is true and there are no values', () => {
let onChangeSpy = jest.fn();
let { container } = render(
<Select
{...BASIC_PROPS}
backspaceRemovesValue
isClearable
isMulti
onChange={onChangeSpy}
/>
);
fireEvent.keyDown(container.querySelector('.react-select__control')!, {
keyCode: 8,
key: 'Backspace',
});
expect(onChangeSpy).not.toHaveBeenCalled();
});

test('multi select > clicking on X next to option will call onChange with all options other that the clicked option', () => {
let onChangeSpy = jest.fn();
let { container } = render(
Expand Down
2 changes: 1 addition & 1 deletion packages/react-select/src/internal/useScrollLock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const LOCK_STYLES = {
};

function preventTouchMove(e: TouchEvent) {
e.preventDefault();
if (e.cancelable) e.preventDefault();
}

function allowTouchMove(e: TouchEvent) {
Expand Down

0 comments on commit fa51804

Please sign in to comment.