Skip to content

Commit 21ac8dc

Browse files
author
Fred Heusschen
committed
focus fix
1 parent 72d4ec1 commit 21ac8dc

File tree

9 files changed

+22
-26
lines changed

9 files changed

+22
-26
lines changed

demo/onepage.html

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -103,15 +103,15 @@ <h2>API</h2>
103103

104104
<script>
105105
new Mmenu(document.querySelector("#menu"), {
106-
pageScroll: {
107-
scroll: true,
108-
update: true,
109-
},
110-
sidebar: {
111-
expanded: {
112-
use: 800,
113-
},
114-
},
106+
// pageScroll: {
107+
// scroll: true,
108+
// update: true,
109+
// },
110+
// sidebar: {
111+
// expanded: {
112+
// use: 800,
113+
// },
114+
// },
115115
});
116116
</script>
117117
</body>

dist/core/offcanvas/mmenu.offcanvas.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/core/offcanvas/mmenu.offcanvas.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -121,13 +121,12 @@ Mmenu.prototype.open = function () {
121121
}
122122
// Invoke "before" hook.
123123
this.trigger('open:before');
124-
var clsn = ['mm-wrapper--opened'];
125-
this.node.wrpr.classList.add(...clsn);
126124
// Open
127125
this.node.menu.classList.add('mm-menu--opened');
128126
this.node.wrpr.classList.add('mm-wrapper--opened');
129127
Mmenu.node.blck.classList.add('mm-blocker--blocking');
130128
// Focus the menu.
129+
this.node.open = document.activeElement;
131130
this.node.menu.focus();
132131
// Invoke "after" hook.
133132
this.trigger('open:after');
@@ -143,7 +142,7 @@ Mmenu.prototype.close = function () {
143142
this.node.wrpr.classList.remove('mm-wrapper--opened');
144143
Mmenu.node.blck.classList.remove('mm-blocker--blocking');
145144
// Focus opening link or page.
146-
const focus = document.querySelector(`[href="#${this.node.menu.id}"]`) || this.node.page || null;
145+
const focus = this.node.open || document.querySelector(`[href="#${this.node.menu.id}"]`) || this.node.page || null;
147146
(_a = focus) === null || _a === void 0 ? void 0 : _a.focus();
148147
// Invoke "after" hook.
149148
this.trigger('close:after');

0 commit comments

Comments
 (0)