Skip to content

Commit

Permalink
Merge pull request #581 from jasny/dropdown_menu_item_click_causes_pa…
Browse files Browse the repository at this point in the history
…ge_going_below_the_offcanvas_menu

Fix bug caused by menu clone (fixes #484)
  • Loading branch information
jasny committed Oct 10, 2018
2 parents 19ebcff + 59af819 commit a542efa
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions js/offcanvas.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@
recalc: true,
disableScrolling: true,
modal: false,
backdrop: false,
exclude: null
}

Expand Down Expand Up @@ -408,9 +409,10 @@
}

OffCanvas.prototype.autohide = function (e) {
if ($(e.target).closest(this.$element).length === 0) this.hide()
var target = $(e.target);
if (!target.hasClass('dropdown-backdrop') && $(e.target).closest(this.$element).length === 0) this.hide()
var $target = $(e.target);
var doHide = !$target.hasClass('dropdown-backdrop') && $target.closest(this.$element).length === 0;

if (doHide) this.hide()
}

// OFFCANVAS PLUGIN DEFINITION
Expand All @@ -424,6 +426,10 @@
var data = $this.data('bs.offcanvas')
var options = $.extend({}, OffCanvas.DEFAULTS, $this.data(), typeof option === 'object' && option)

//In case if user does smth like $('.navmenu-fixed-left').offcanvas('hide'),
//thus selecting also menu clone (that can cause issues)
if ($this.hasClass('offcanvas-clone')) return

if (!data) $this.data('bs.offcanvas', (data = new OffCanvas(this, options)))
if (typeof option === 'string') data[option]()
})
Expand Down

0 comments on commit a542efa

Please sign in to comment.