JedWatson / react-select

The Select Component for React.js
https://react-select.com/
MIT License
27.42k stars 4.1k forks source link

Select not scrolling to Selected Item when menuPortalTarget={document.body} #5926

Open jfishymlb opened 1 week ago

jfishymlb commented 1 week ago

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

Screenshot 2024-06-24 at 1 14 49 PM

Switching to menuPortalTarget={null} resolves the issue