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

Can dismissible popover work without href="#" ? #15277

Closed
bartvanderwal opened this issue Dec 3, 2014 · 16 comments
Closed

Can dismissible popover work without href="#" ? #15277

bartvanderwal opened this issue Dec 3, 2014 · 16 comments
Labels
Milestone

Comments

@bartvanderwal
Copy link

The dismissable popover is not working for me in Bootstrap 3.3.1. No popup window appears anymore when I add a data-trigger="focus" attribute.

See this fiddle:
http://jsfiddle.net/bartvanderwal/qjaL0tp4/

By comparing it in detail with the standard Bootstrap example on your website I found out that this can be fixed by adding a href="#'. See this Fiddle:
http://jsfiddle.net/bartvanderwal/29hbf4no/

But I'd prefer not to need a href 😄, and that does works for the non-dismissable version, so it'd be more consistent.

@cvrebert
Copy link
Collaborator

cvrebert commented Dec 3, 2014

So, do you have a specific working change that you're proposing, or are you just asking whether we know of some alternative that doesn't involve href="#" ?

@georgeoffley
Copy link

If you change the data-trigger="focus" to data-trigger="click" that eliminates the need for an href tag. Maybe something like that would help.

@cvrebert
Copy link
Collaborator

cvrebert commented Dec 3, 2014

data-trigger="click" does not dismiss the popover when you click elsewhere on the page.
data-trigger="focus" does. That's the point of that example.

@georgeoffley
Copy link

I got it to work with the button attributes when I changed it to data-trigger="click focus".
See jsfiddle:
http://jsfiddle.net/goffley3/aj62yb7w/

@cvrebert
Copy link
Collaborator

cvrebert commented Dec 3, 2014

data-trigger="click focus" causes the popover to open and then immediately close when initially clicked (at least on OS X Chrome).

@cvrebert cvrebert changed the title Dismissable popover does not work without anchor Dismissible popover does not work without href="#" Dec 3, 2014
@georgeoffley
Copy link

Oh so I just added the tabindex="0" to the link and was able to have it work with the data-trigger="focus" without the href=#

JSFiddle: http://jsfiddle.net/goffley3/kdh9xxp9/

@cvrebert
Copy link
Collaborator

cvrebert commented Dec 3, 2014

Interestingly, removing href="#" makes the button focusable via keyboard tabbing in Safari.
Given that we're already using tabindex="0" and that .btn sets cursor: pointer, we might indeed not actually need the href attribute.
@mdo Anything I might be overlooking here?

@georgeoffley
Copy link

@cvrebert @mdo Looking through the documentation it explains it as well http://getbootstrap.com/javascript/#popovers

@cvrebert
Copy link
Collaborator

cvrebert commented Dec 4, 2014

@georGEO1989 Huh?

@georgeoffley
Copy link

@cvrebert In that section under "Dismiss on next click" on the link http://getbootstrap.com/javascript/#popovers it says that to make the popover disappear you need to add the tabindex attribute for the data-trigger="focus" to work. AT least that's how I'm reading it I could be wrong but I tried that and it worked. 😄

@cvrebert
Copy link
Collaborator

cvrebert commented Dec 4, 2014

Right, I'm aware of that. I wrote that part of those docs. The question here is about href, not tabindex.

@georgeoffley
Copy link

Oh I'm sorry my bad. This is my first attempt to contribute to an open source project 😳

@bartvanderwal
Copy link
Author

@cvrebert Thanks for the quick response. I was a bit busy with other stuff. As I mentioned I think it would be best if this worked without href. But I don't have a working change for that myself. I'm going with using tabindex="x" property suggested instead of a dummy `href="#' now, as that makes sense functionaly. Thanks @georGEO1989, for the suggestion (and your first open source contribution) :smile ; keep it up!

My best suggestion would be to add a remark in the Dismiss on next click section just below the 'dismissable popover' example that either the href of the tabindex attribute has to be present required for this too work. Or just keep it like it is, you guys must be busy as well.

@cvrebert cvrebert changed the title Dismissible popover does not work without href="#" Can dismissible popover work without href="#" ? Dec 17, 2014
@cvrebert cvrebert added this to the v3.3.2 milestone Jan 6, 2015
@cvrebert
Copy link
Collaborator

I tested http://jsbin.com/zuzoce/5 (which removes the href="#") on all our supported platforms, and it seems to still work fine. And it's valid HTML5.
@patrickhlauke @mdo So, you guys okay with removing the href="#" from the dismissible popover example?

@mdo
Copy link
Member

mdo commented Jan 18, 2015

Removing the href is fine by me.

@Bounpakhong
Copy link

Why all you don't use href="#_" :)

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

5 participants