Skip to content

Commit 5372a84

Browse files
author
Fred Heusschen
committed
backbutton fix
1 parent 2eb2f02 commit 5372a84

File tree

5 files changed

+15
-15
lines changed

5 files changed

+15
-15
lines changed

dist/addons/backbutton/mmenu.backbutton.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,34 +11,34 @@ export default function () {
1111
const _menu = `#${this.node.menu.id}`;
1212
// Close menu
1313
if (options.close) {
14-
var states = [];
14+
let states = [];
1515
const setStates = () => {
1616
states = [_menu];
1717
DOM.children(this.node.pnls, '.mm-panel--opened, .mm-panel--parent').forEach((panel) => {
1818
states.push('#' + panel.id);
1919
});
2020
};
2121
this.bind('open:after', () => {
22-
history.pushState(null, document.title, _menu);
22+
history.pushState(null, '', location.pathname + location.search + _menu);
2323
});
2424
this.bind('open:after', setStates);
2525
this.bind('openPanel:after', setStates);
2626
this.bind('close:after', () => {
2727
states = [];
2828
history.back();
29-
history.pushState(null, document.title, location.pathname + location.search);
29+
history.pushState(null, '', location.pathname + location.search);
3030
});
31-
window.addEventListener('popstate', (evnt) => {
31+
window.addEventListener('popstate', () => {
3232
if (this.node.menu.matches('.mm-menu--opened')) {
3333
if (states.length) {
3434
states = states.slice(0, -1);
35-
var hash = states[states.length - 1];
35+
const hash = states[states.length - 1];
3636
if (hash == _menu) {
3737
this.close();
3838
}
3939
else {
4040
this.openPanel(this.node.menu.querySelector(hash));
41-
history.pushState(null, document.title, _menu);
41+
history.pushState(null, '', location.pathname + location.search + _menu);
4242
}
4343
}
4444
}

dist/mmenu.js

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

package-lock.json

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

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "mmenu-js",
3-
"version": "9.2.2",
3+
"version": "9.2.3",
44
"main": "dist/mmenu.js",
55
"module": "src/mmenu.js",
66
"author": "Fred Heusschen <[email protected]>",

src/addons/backbutton/mmenu.backbutton.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ export default function (this: Mmenu) {
1818

1919
// Close menu
2020
if (options.close) {
21-
var states = [];
21+
let states = [];
2222

2323
const setStates = () => {
2424
states = [_menu];
@@ -31,7 +31,7 @@ export default function (this: Mmenu) {
3131
};
3232

3333
this.bind('open:after', () => {
34-
history.pushState(null, document.title, _menu);
34+
history.pushState(null, '', location.pathname + location.search + _menu);
3535
});
3636
this.bind('open:after', setStates);
3737
this.bind('openPanel:after', setStates);
@@ -40,22 +40,22 @@ export default function (this: Mmenu) {
4040
history.back();
4141
history.pushState(
4242
null,
43-
document.title,
43+
'',
4444
location.pathname + location.search
4545
);
4646
});
4747

48-
window.addEventListener('popstate', (evnt) => {
48+
window.addEventListener('popstate', () => {
4949
if (this.node.menu.matches('.mm-menu--opened')) {
5050
if (states.length) {
5151
states = states.slice(0, -1);
52-
var hash = states[states.length - 1];
52+
const hash = states[states.length - 1];
5353

5454
if (hash == _menu) {
5555
this.close();
5656
} else {
5757
this.openPanel(this.node.menu.querySelector(hash));
58-
history.pushState(null, document.title, _menu);
58+
history.pushState(null, '', location.pathname + location.search + _menu);
5959
}
6060
}
6161
}

0 commit comments

Comments
 (0)