Skip to content

Commit

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

* Use ResizeObserver to update menu position if available

Fixes JedWatson#5403.

I mistakenly thought in JedWatson#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 and Rall3n committed Oct 21, 2022
1 parent d2dd0f9 commit d57a893
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 d57a893

Please sign in to comment.