-
Notifications
You must be signed in to change notification settings - Fork 4.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Dropdown doesn't close when I click outside the dropdown #2239
Comments
I have the same issue apparently the version compiled doesn't match with source code @JedWatson the event bubble is stopped |
I am also having this issue. Are there any stop-gap solutions? |
It works fine on the website/demo page, but I'm stuck on this too |
@jvega it seems more related to the fact that the drop down input doesn't gain focus (at least for me) when I click the arrow to reveal the drop down contents. If I click outside of the dropdown and it doesn't have focus, it doesn't auto hide the drop down contents. On the demo page, if you click the drop down arrow, the selects gain focus automatically, but I don't see anything in the example code causing that to happen manually, so it seems like it's a library feature that isn't working. edit: okay - it doesn't gain focus because of the event bubble stoppage :) |
Same here. |
if you check the screenshots that I attach above, the compiled version that was distributed trough NPM (21 days ago) it doesn't match with source version, the 1.2.0 version fix this bug |
Thanks for reporting this. I can confirm after upgrading from 1.1.0 to 1.2.0 that the outside click bug has been resolved. Edit: I'm still encountering an issue for |
I've update the package in my project to the 1.2.1 version and it's still not working :/ |
Same here, not working on 1.2.1 |
I had this issue when I applied a |
I faced the same issue, not able to close the multi select dropdown when I click outside it. It works fine for normal dropdown. Any solution. I have the latest version of react-select installed. |
Same problem with "react-select": "3.0.8" |
same problem with "react-select": "3.0.8" |
Hi @deniswvieira and @juliocarneiro, I'm unable to replicate this with a multi select dropbox, could you please provide a CodeSandbox with the same options you're using so I can look into this further, and also let me know which browser version you're having trouble with. I've created one here for my testing - https://codesandbox.io/s/react-select-v3-sandbox-nl4yg |
This issue will now be closed due to inactivity. If anyone can reproduce this bug and provide a Codesandbox example, please let me know and the issue will be re-opened. |
IndicatorSeparator: () => null, If such configuration provided, as valueconatiner is null, it will not close your optionbox on outside click.If anyone have solution.Please provide. |
If value container is not displayed then this issue happens. I suppose that it uses some kind of css or some property from the value container for the close operation when clicked outside. |
Greetings @kulkarnipradnyas, @binoyskumar92 is correct. The react-select component relies on the However, as long as there is another component within the demo: codesandbox Let me know if you have any other questions. |
This issue should not be closed, it's still relevant. If ValueContainer is set then the dropdown won't close. |
Greetings @tania-balto
Can you elaborate or better yet include a codesandbox demonstrating the incorrect behavior? |
Greetings, @ebonow. Sorry for the curt response. In my case, I used this code to update the value container to display "{x} selected" if more than one item is selected, and show the item itself if only one is selected, which hopefully helps anyone in the future. const ValueContainer = ({ children, ...props }) => {
const { length } = props.getValue();
const selectOptionsAndInput = React.Children.map(children, (child) => {
if (child && [components.SingleValue].indexOf(child.type) === -1) {
return child;
}
return null;
});
const searchInput = last(selectOptionsAndInput);
if (length > 1) {
return (
<components.ValueContainer {...props}>
<div className="option-label">{`${length} selected`}</div>
{searchInput}
</components.ValueContainer>
);
}
return <components.ValueContainer {...props}>{selectOptionsAndInput}</components.ValueContainer>;
}; The dropdown wouldn't close if I clicked outside, but it was because I tried currying and passing a value in at the |
I'm glad you were able to get this resolved. This isn't an uncommon issue and recently this section was added to the documentation to better help identify this frustrating behavior. Regarding your solution, have you tried overriding the const MultiValue = props => {
// Only interested in rendering one/first multiValue
if (props.index > 0) return null;
const { length } = props.getValue();
return (length > 1)
? <div className="option-label">{`${length} selected`}</div>
: <components.MultiValue {...props} />
} The component prop does not seem to appear in the documentation anymore so I'll look into what happened there but likely something lost in translation from Flow to TypeScript. |
Thanks for the follow up, I'll try that out. I think I tried that approach earlier but it probably wasn't working due to the issue I resolved, so I'll try again. |
@andrewpashko would you kindly create a new discussion under q&a preferably with a codesandbox link so that someone can help you with your particular implementation. |
hey, i am stuck with the same problem, can you tell me what is last keyword you used here " last(selectOptionsAndInput); " i am also defining the value container outside the component
};` |
Hi when I show the dropdown menu and then click outside the region of dropdown it doesn't close.
Why?
Here is how I create it
The text was updated successfully, but these errors were encountered: