JedWatson / JedWatson/react-select
Select not scrolling to Selected Item when menuPortalTarget={document.body}
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 28k
- Forks
- 4.1k
- PR merge metrics
- No merged PRs in 30d
Description
When setting the MenuPortalTarget prop to document.body it breaks the functionality of correctly scrolling/focusing on the selected Item when it is at the bottom/out of view in the options list.
Example Code from the sandbox:
<Select
className="basic-single"
classNamePrefix="select"
defaultValue={colourOptions[0]}
isDisabled={isDisabled}
isLoading={isLoading}
isClearable={isClearable}
isRtl={isRtl}
isSearchable={isSearchable}
name="color"
options={colourOptions}
menuPortalTarget={document.body}
/>
Image of Silver which is the last option not showing when it is selected and the select is opened again
Switching to menuPortalTarget={null} resolves the issue
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
Start by reproducing the sandbox example with menuPortalTarget set to document.body, then compare it with menuPortalTarget={null}. Trace the select menu's selected-item focus and scrolling behavior in the portal case; done means a selected option at the bottom or outside the visible list is scrolled into view when the menu reopens.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- react, typescript
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100