JedWatson / JedWatson/react-select
ResizeObserver error when using React Select in React 16 and 17
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 28k
- Forks
- 4.1k
- PR merge metrics
- No merged PRs in 30d
Description
Overview
My app is listening for error event in window object to display errors those are not handled by components. We are using react-select with properties isMulti set to true, menuPosition set to fixed and menuIsOpen set to true until user clicks outside. The error handler receives following error when user selects multiple options and the height of input of React Select grows.
Error:
ResizeObserver loop completed with undelivered notifications.
Implementation Details
React version: 16 and 17. This error is not received in React 18.
React Select version: 5.7.5
Code:
React 17: https://codesandbox.io/s/react-select-v5-resizeobserver-j2plzh?file=/example.js
React 16: https://codesandbox.io/s/react-select-resizer-issue-react16-65xdsp?file=/example.tsx
React 18: https://codesandbox.io/s/react-select-resizer-issue-react18-qdnpp9?file=/src/App.js
Listening for unhandled errors:
window.addEventListener("error", (e) => {
console.error("global error (ErrorEvent) - ", e);
alert("Error - " + e.message);
});
Usage of ReactSelect
import Select from "react-select";
import { colourOptions } from "./docs/data";
const SingleSelect = () => (
<div style={{ width: "300px" }}>
<Select
className="basic-single"
classNamePrefix="select"
name="color"
options={colourOptions}
isMulti
menuPosition="fixed"
menuIsOpen={true}
/>
</div>
);
Steps to reproduce:
Select multiple options. When the input grows the height, the error handler receives the error. Similarly, when we deselect values, and the height of input shrinks, the error handler receives the error.
Expectation
The error is not raised while the height of React Select input grows or shrinks; or a we have way to ignore this error in component level.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the behavior using the linked React 16 and React 17 CodeSandbox examples, comparing them with the React 18 example. Inspect how the multi-select input changes height while menuPosition is fixed and menuIsOpen is true; done means selecting and deselecting options no longer delivers the ResizeObserver error to the window error handler, or the component provides a documented way to ignore it.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- react, typescript
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100