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

Tooltip/Popover methods show/hide/toggle don't work properly with click triggering #16732

Closed
zandroid opened this issue Jun 30, 2015 · 12 comments

Comments

@zandroid
Copy link

After upgrading to version 3.3.5 I have found a couple of issues with popover. Original issue is I need to click twice by trigger element $el if popover was hidden by $el.popover('hide'). You can reproduce it here: https://jsbin.com/bapohu/edit?html,js,output.
It looks like a state is saved into inState by events but not changed by calling of methods. commit

Another issues:
Need twice click by trigger to hide popover after $el.popover('show')

  • Click by [show]
  • Click by [trigger], note the popover is not hidden
  • Click by [trigger] again, the popover is hidden

Opened by trigger the popover cannot be hidden by $el.popover('toggle')

  • Click by [trigger]
  • Click by [toggle], note the popover is not hidden
@cvrebert cvrebert added this to the v3.3.6 milestone Jul 1, 2015
@cvrebert
Copy link
Collaborator

cvrebert commented Jul 1, 2015

CC: @redbmk @fat

@cvrebert cvrebert changed the title Tooltip/Popover methods show/hide/toggle don't work properly Tooltip/Popover methods show/hide/toggle don't work properly with click triggering Jul 1, 2015
@fat
Copy link
Member

fat commented Jul 1, 2015

hm… we could just revert @redbmk's commit

@cvrebert
Copy link
Collaborator

cvrebert commented Jul 1, 2015

...which would re-break #16008.

@redbmk
Copy link
Contributor

redbmk commented Jul 1, 2015

Maybe manual triggers could reset inState back to its initial settings

@julesongithub
Copy link

You can apply a temporary fix in the hidden event like this:

$('body').on('hidden.bs.popover', function (e) {
    $(e.target).data("bs.popover").inState.click = false;
});

@redbmk
Copy link
Contributor

redbmk commented Dec 16, 2015

@julesongithub This has been fixed for a while in pull request #17702, but is still waiting on code review.

@cvrebert
Copy link
Collaborator

@whythecode @gregblass Per our issue tracker guidelines, please use GitHub's "reactions" feature instead of posting noisy "+1" comments.

@markbao
Copy link

markbao commented Jul 12, 2016

Sigh. This is still an issue in 4.0.

Adapting @julesongithub's patch, one can fix this in 4.0 using:

$('body').on('hidden.bs.popover', function (e) {
    $(e.target).data("bs.popover")._activeTrigger.click = false;
});

@cvrebert cvrebert removed this from the v3.3.7 milestone Jul 25, 2016
@mdo
Copy link
Member

mdo commented Sep 5, 2016

Bootstrap 3 is no longer being officially developed or supported.

All work has moved onto our next major release, v4. As such, this issue or pull request is being closed as a "won't fix." For additional help and support, we recommend utilizing our community resources. Thanks for your understanding, and see you on the other side of v4!

<3,
@mdo and team

@mdo mdo closed this as completed Sep 5, 2016
@cvrebert
Copy link
Collaborator

cvrebert commented Sep 5, 2016

Reopening since this also has the v4 label.

@kingsloob1
Copy link

When you use tooltip custom triggers like click,focus, etc except trigger, bootstrap assigns an event handler once clicked or focused for the first time. Then on the second attempt, the event get's executed. So to avoid this, use this

$(element).popover({"trigger":"manual"}};
Then call the popover using
$(element).popover('show');

@RosalynLP
Copy link

Sigh. This is still an issue in 4.0.

Adapting @julesongithub's patch, one can fix this in 4.0 using:

$('body').on('hidden.bs.popover', function (e) {
    $(e.target).data("bs.popover")._activeTrigger.click = false;
});

Just fyi using this fix gave me some problems from within R shiny with the conditional panels I was using elsewhere; it seems that 'hidden.bs.popover' is also triggered when hiding a conditional panel (not sure why as they don't have popover class), but if you set click to false here the content does not always display when the condition is changed. To get around it I added a line checking the class of the target which hides the popover - in this case all my popovers are called by buttons with class 'summary-btn' so I check that before resetting the click state.

$(document).on('hidden.bs.popover', (x) => {
    if($(x.target).attr("class") !== undefined){
        if($(x.target).attr("class").includes("summary-btn")){
            $(x.target).data("bs.popover").inState = { click: false, hover: false, focus: false };
        } 
   }
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

9 participants