Add support for menuScrollIntoViewElement #3531
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Current behavior
Currently,
react-select
tries to find the appropriate element to scroll by traversing parents and finding a parent withoverflow=scroll / auto
and defaults to the root document. Seereact-select/src/utils.js
Lines 127 to 143 in 292bad3
This doesn't work a
react-select
element is positioned inside a static positioned parent (example using CSS Grid).Suggestion
This PR adds a new
menuScrollIntoViewElement
to support this custom behavior. You can try this PR out here: https://codepen.io/skovhus/pen/JVVGdOIt does not solve all use cases, as there is still code that checks for available view height on window (
viewSpaceBelow >= menuHeight
), and not inside the container. HeremenuScrollIntoViewElement
does not have any effect (yet). Demo https://codepen.io/skovhus/pen/LvvNJERelated issues
#810
TODO