Skip to content

Commit

Permalink
Use ResizeObserver to auto-update menu position if available (#5404)
Browse files Browse the repository at this point in the history
* Use ResizeObserver to update menu position if available

Fixes #5403.

I mistakenly thought in #5381 that the resize event was placed on the control element, but's it really just on the scroll parents of the control element.

This PR enables `ResizeObserver` if it's available. The referenced issue demonstrates a good use-case for it.

* Create tricky-books-design.md
  • Loading branch information
Methuselah96 authored Oct 20, 2022
1 parent a0421af commit ebb0a17
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/tricky-books-design.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'react-select': patch
---

Use ResizeObserver to auto-update menu position if available
2 changes: 1 addition & 1 deletion packages/react-select/src/components/Menu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -648,7 +648,7 @@ export const MenuPortal = <
controlElement,
menuPortalRef.current,
updateComputedPosition,
{ elementResize: false }
{ elementResize: 'ResizeObserver' in window }
);
}
}, [controlElement, updateComputedPosition]);
Expand Down

0 comments on commit ebb0a17

Please sign in to comment.