Skip to content
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 forms disappears on click #26189

Closed
vosidiy opened this issue Apr 3, 2018 · 10 comments
Closed

Dropdown forms disappears on click #26189

vosidiy opened this issue Apr 3, 2018 · 10 comments
Labels

Comments

@vosidiy
Copy link

vosidiy commented Apr 3, 2018

I made dropdown login form, When you click on content of the dropdown it will close
1

@vosidiy
Copy link
Author

vosidiy commented Apr 3, 2018

I think it should close only for outside click, not inside dropdown.
Check this github's top right button and click on text "Signed in as". it will not close.

@patrickhlauke
Copy link
Member

bug reports / issues need a working reduced test case showing the problem.

for what it's worth, out of the box bootstrap's form dropdowns don't close when clicking outside of links/form controls - see https://www.bootply.com/mhuf1l1jAV ... so might be a problem with whatever extra code you're running

@vosidiy
Copy link
Author

vosidiy commented Apr 4, 2018

@patrickhlauke
Only when you use the < form > tag for dropdown-menu it will work. Otherwise, it is closing on click
Check this demo
https://codepen.io/vosidiy/pen/BrPqjQ

@Johann-S
Copy link
Member

Johann-S commented Apr 4, 2018

That's due to this line: https://github.com/twbs/bootstrap/blob/v4-dev/js/src/dropdown.js#L57

But @vosidiy can you explain to us why it's an issue ? Because you just have to add a form tag to make it works

@vosidiy
Copy link
Author

vosidiy commented Apr 4, 2018

@Johann-S then how to create tabs or some clickable element inside the dropdown-menu

(see screenshot example, there is no any form element)
So should we use always < form > tag even if there is no form element?

1

@Johann-S
Copy link
Member

Johann-S commented Apr 4, 2018

that's right seems to me a valid use case.

Any concerns @patrickhlauke or @mdo ?

@patrickhlauke
Copy link
Member

patrickhlauke commented Apr 4, 2018

indeed it would make sense to keep the dropdowns more generic and to swallow (as in, don't close the dropdown) any clicks inside the dropdown container itself regardless of content. authors WILL use dropdowns for any sort of arbitrary content beyond just forms, so i'd rather see us tackle this use case directly instead of expecting authors to have to hack it.

@italodirenzo93
Copy link

I'd like to try tackling this issue. Has it been agreed upon that dropdowns will not auto-close on clicks made inside the container?

@RyanBerliner
Copy link
Contributor

I know this is an older issue, but the behavior is still present in BS4 and (if I'm looking at the correct place) planned for BS5 as well. I'd also like to suggest that dropdowns do not toggle closed when clicking inside of them (by default, at least).

https://github.com/twbs/bootstrap/blob/main/js/src/dropdown.js

The dropdown js confirms the behavior that clicking inside of a form within the dropdown does not close the dropdown, but clicking elsewhere inside the dropdown does. There are many use cases where you'd want the dropdown to stay open outside of using a form within it. For example, let's say there is a dropdown full of links, and you click one. I'd think the dropdown should stay open until either the new location loads, or you manually trigger a closure after something happens. When it disappears as it currently does, it can be disorienting.

I'd argue it is almost always going to be a better user experience for the item you click on to remain visible. Is there a major use case I'm missing or not understanding as to why dropdowns close when clicking inside of them currently?

@mdo mdo changed the title Dropdown forms disapperas on click Dropdown forms disappears on click Jan 12, 2021
@mdo
Copy link
Member

mdo commented Sep 6, 2021

This was addressed with #33389.

@mdo mdo closed this as completed Sep 6, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

6 participants