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

Popover with data-trigger:focus not close when click in button again. Usability? #16802

Closed
adrianoresende opened this issue Jul 10, 2015 · 11 comments
Labels

Comments

@adrianoresende
Copy link

Usability improvise if close popover when button is clicked again, equal behavior without data-trigger.
Or new mini button with icon close in top-right in popover

@patrickhlauke
Copy link
Member

The problem here would be that if focus is what is triggering the popover, then clicking the same trigger again would still keep the focus on the trigger. To modify the current implementation would require to keep track somehow of "although this trigger has focus, we've already shown the popover and the user clicked on the trigger again, so don't show the popover again", which would also need to be reset as soon as focus eventually leaves the trigger (e.g. if the user clicked on something else). Not quite sure it's worth the implementation pain...

@adrianoresende
Copy link
Author

Htmm.. well, with div.modal-backdrop (transparent) not is good, why need to click two time in another button in page.
Now I understand that it's complicated.
Who know, maybe with the new technology javascript solves hehehe

@cvrebert cvrebert added the js label Jul 10, 2015
@cvrebert cvrebert added the v3 label Aug 19, 2015
@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
@d13
Copy link

d13 commented Oct 20, 2016

This issue still happens in v4, so I definitely think it should be kept open.

@czerthas
Copy link

czerthas commented Jun 30, 2017

data-trigger="manual"

$('[data-trigger="manual"]').click(function() {
    $(this).popover('toggle');
}).blur(function() {
    $(this).popover('hide');
});

@princenaman
Copy link

data-trigger="manual"

$('[data-trigger="manual"]').click(function() {
    $(this).popover('toggle');
}).blur(function() {
    $(this).popover('hide');
});

Cannot get it to work 😞

@qesya
Copy link

qesya commented Oct 11, 2018

Any news about it?

@abhi90g
Copy link

abhi90g commented May 14, 2019

Facing same issue in v4. Cannot close popover on clicking button again if triggers='focus' is used.
Tried the same with bootstrap-vue v2.0.0-rc.19

An update on this would be appreciated

@ksr007
Copy link

ksr007 commented Jul 8, 2019

Suppose my popover is mapped with ID "settingMenuPopover" and trigger is set as 'focus'.

Then this handling of popover open and close work for me :

  var isSettingMenuPopoverVisible = false;  //assuming popovers are hidden by default
  var settingMenuPopoverOpenCounter = 0;   // to handle first time open case (Issue : first time open as flickering ) 
  var settingMenuPopoverManualClose = false;
      $('#settingMenuPopover').on('shown.bs.popover', function () {
        isSettingMenuPopoverVisible = true;
      })

      $('#settingMenuPopover').on('hidden.bs.popover', function () {
        if (!settingMenuPopoverManualClose) {
          settingMenuPopoverOpenCounter = 0; // set openCounter 0 to automatically closed popover to prevent flickering of popover at next time
        }
        settingMenuPopoverManualClose = false;
        isSettingMenuPopoverVisible = false;
      })

      $("#settingMenuPopover").on("click", function(){
          if (isSettingMenuPopoverVisible) {
              settingMenuPopoverOpenCounter += 1;
              settingMenuPopoverManualClose = true;
              $('#settingMenuPopover').popover('hide');
          } else if (settingMenuPopoverOpenCounter > 0) {
              $('#settingMenuPopover').popover('show');
          }
      });

@ravimisra
Copy link

ravimisra commented Jul 31, 2019

A more optimized way to achieve the same thing:
popover params:

{          
    trigger: 'click',
    tabindex: 0
}
       $('#settingMenuPopover').on('shown.bs.popover', function (e) {
            var target = e.target;
            $(document).one('click', function(e) {
                var clicked = e.target;
                if (clicked != target && clicked.parentElement != target) {
                    $(target).trigger('click');
                } 
            });
        });

@RaminPakzad
Copy link

You can use focus and click together.
trigger: 'focus click'

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