Skip to content

Commit a542efa

Browse files
authored
Merge pull request #581 from jasny/dropdown_menu_item_click_causes_page_going_below_the_offcanvas_menu
Fix bug caused by menu clone (fixes #484)
2 parents 19ebcff + 59af819 commit a542efa

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

js/offcanvas.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@
6161
recalc: true,
6262
disableScrolling: true,
6363
modal: false,
64+
backdrop: false,
6465
exclude: null
6566
}
6667

@@ -408,9 +409,10 @@
408409
}
409410

410411
OffCanvas.prototype.autohide = function (e) {
411-
if ($(e.target).closest(this.$element).length === 0) this.hide()
412-
var target = $(e.target);
413-
if (!target.hasClass('dropdown-backdrop') && $(e.target).closest(this.$element).length === 0) this.hide()
412+
var $target = $(e.target);
413+
var doHide = !$target.hasClass('dropdown-backdrop') && $target.closest(this.$element).length === 0;
414+
415+
if (doHide) this.hide()
414416
}
415417

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

429+
//In case if user does smth like $('.navmenu-fixed-left').offcanvas('hide'),
430+
//thus selecting also menu clone (that can cause issues)
431+
if ($this.hasClass('offcanvas-clone')) return
432+
427433
if (!data) $this.data('bs.offcanvas', (data = new OffCanvas(this, options)))
428434
if (typeof option === 'string') data[option]()
429435
})

0 commit comments

Comments
 (0)