JedWatson / JedWatson/react-select

menuPortalTarget add event on click on while document

Open
#5,709 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

issue/bug-unconfirmed
Dominant language
TypeScript
Stars
28k
Forks
4.1k
PR merge metrics
No merged PRs in 30d

Description

I have next config
<Select
// isLoading={true}
ref={ref}
className="mobile-list__item__select"
classNamePrefix="mobile-list__item__select"
isSearchable={false}
options={prices}
placeholder={""}
menuPlacement="auto"
onChange={handlerSelect}
components={{ DropdownIndicator }}
menuPortalTarget={document.querySelector("body")}
/>

but when i first time open select, it add event on click to whole doc, and after close menu this click not destroyed.
If I remove menuPortalTarget, event not adding, but i use it for lift up menu.
How I can fix this?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the reported Select configuration with menuPortalTarget={document.querySelector("body")} and compare it with the same select without the portal target. Inspect the menu-open and document-click behavior, then verify that any document-level click handling is removed after the menu closes.

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
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.