JedWatson / JedWatson/react-select

Custom Menu, onClick label closes the react-select menu

Open
#4,996 0 comments 1 reaction 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

Thanks for using react-select!

I have a custom react-select menu and it is added like this:

<Select
    placeholder={'Placeholder}
    components={{
        Menu: CustomMenu,
    }}
    className="ml-6"
    closeMenuOnSelect={false}
></Select>

and if I have some checkbox in the "CustomMenu" component with label and if the label has htmlFor="inputId" onClick on the label, the menu is closed. does anybody know how to solve this problem? i thought that closeMenuOnSelect="false" will solve the problem, but that is not the case... this is the code for customMenu

    const CustomMenu = (props: MenuProps) => {
        return (
            <components.Menu className="react-select--availability" {...props}>
                <div>
                    <input type="checkbox" id="saka-test" />
                    <label htmlFor="saka-test">grdonifgeornh</label>
                </div>
            </components.Menu>
        );
    };

here is the sandbox with an example:

https://codesandbox.io/s/jovial-roentgen-ptqe7?file=/src/App.js

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 with the reproduction in the linked CodeSandbox, especially src/App.js and the CustomMenu component shown in the issue. Trace how clicking the label interacts with the custom menu and closeMenuOnSelect; done means clicking the checkbox label no longer closes the menu while preserving normal selection behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
frontend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.