Skip to content

Commit

Permalink
focus fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Fred Heusschen committed Apr 2, 2022
1 parent 72d4ec1 commit 21ac8dc
Show file tree
Hide file tree
Showing 9 changed files with 22 additions and 26 deletions.
18 changes: 9 additions & 9 deletions demo/onepage.html
Original file line number Diff line number Diff line change
Expand Up @@ -103,15 +103,15 @@ <h2>API</h2>

<script>
new Mmenu(document.querySelector("#menu"), {
pageScroll: {
scroll: true,
update: true,
},
sidebar: {
expanded: {
use: 800,
},
},
// pageScroll: {
// scroll: true,
// update: true,
// },
// sidebar: {
// expanded: {
// use: 800,
// },
// },
});
</script>
</body>
Expand Down
2 changes: 1 addition & 1 deletion dist/core/offcanvas/mmenu.offcanvas.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 2 additions & 3 deletions dist/core/offcanvas/mmenu.offcanvas.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,13 +121,12 @@ Mmenu.prototype.open = function () {
}
// Invoke "before" hook.
this.trigger('open:before');
var clsn = ['mm-wrapper--opened'];
this.node.wrpr.classList.add(...clsn);
// Open
this.node.menu.classList.add('mm-menu--opened');
this.node.wrpr.classList.add('mm-wrapper--opened');
Mmenu.node.blck.classList.add('mm-blocker--blocking');
// Focus the menu.
this.node.open = document.activeElement;
this.node.menu.focus();
// Invoke "after" hook.
this.trigger('open:after');
Expand All @@ -143,7 +142,7 @@ Mmenu.prototype.close = function () {
this.node.wrpr.classList.remove('mm-wrapper--opened');
Mmenu.node.blck.classList.remove('mm-blocker--blocking');
// Focus opening link or page.
const focus = document.querySelector(`[href="#${this.node.menu.id}"]`) || this.node.page || null;
const focus = this.node.open || document.querySelector(`[href="#${this.node.menu.id}"]`) || this.node.page || null;
(_a = focus) === null || _a === void 0 ? void 0 : _a.focus();
// Invoke "after" hook.
this.trigger('close:after');
Expand Down
Loading

0 comments on commit 21ac8dc

Please sign in to comment.