The Bootstrap popup will disappear by right-clicking on Firefox

I have some kind of problem with twitter-bootstrap and firefox. I have a button and a drop-down menu with input text. If I right-click on a tab (for example, for right-click + paste), Firefox closes the drop-down list. And it's pretty boring.

Is there any solution to prevent this behavior?

Thank!

+5
source share
2 answers

As an immediate workaround, you can use something in the following lines to prevent the click event from propagating when the click event is a right-click

Js

$(document).on('click', function(e) {
  e.button === 2 && e.stopImmediatePropagation()
})

jQuery Bootstrap.

Plunk

, , , - , .


Update

- , .

JS

// obtain a reference to the original handler
var _clearMenus = $._data(document, "events").click.filter(function (el) {
    return el.namespace === 'data-api.dropdown' && el.selector === undefined
  })[0].handler;

// disable the old listener
$(document)
  .off('click.data-api.dropdown', _clearMenus)
  .on('click.data-api.dropdown', function (e) {
    // call the handler only when not right-click
    e.button === 2 || _clearMenus()
  })

, Bootstrap.

Plunk

+4

Bootstrap 3 bs.data-api.dropdown.

JS

// obtain a reference to the original handler
var _clearMenus = $._data(document, "events").click.filter(function (el) {
  return el.namespace === 'bs.data-api.dropdown' && el.selector === undefined
})[0].handler;

// disable the old listener
$(document)
  .off('click.data-api.dropdown', _clearMenus)
  .on('click.data-api.dropdown', function (e) {
    // call the handler only when not right-click
    e.button === 2 || _clearMenus()
  })

Plunk

0

All Articles