mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-27 09:06:15 +01:00
fix: #12133 dropdown menus on mobile stay open during ajaxify
This commit is contained in:
@@ -472,6 +472,20 @@ ajaxify.widgets = { render: render };
|
|||||||
hooks.fire('action:ajaxify.cleanup', { url, tpl_url });
|
hooks.fire('action:ajaxify.cleanup', { url, tpl_url });
|
||||||
};
|
};
|
||||||
|
|
||||||
|
ajaxify.handleTransientElements = () => {
|
||||||
|
// todo: modals?
|
||||||
|
|
||||||
|
const elements = ['[component="notifications"]', '[component="chat/dropdown"]', '[component="sidebar/drafts"]', '[component="header/avatar"]']
|
||||||
|
.map(el => document.querySelector(`${el} .dropdown-menu.show`) || document.querySelector(`${el} + .dropdown-menu.show`))
|
||||||
|
.filter(Boolean);
|
||||||
|
|
||||||
|
if (elements.length) {
|
||||||
|
elements.forEach((el) => {
|
||||||
|
el.classList.remove('show');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
translator.translate('[[error:no-connection]]');
|
translator.translate('[[error:no-connection]]');
|
||||||
translator.translate('[[error:socket-reconnect-failed]]');
|
translator.translate('[[error:socket-reconnect-failed]]');
|
||||||
translator.translate(`[[global:reconnecting-message, ${config.siteTitle}]]`);
|
translator.translate(`[[global:reconnecting-message, ${config.siteTitle}]]`);
|
||||||
@@ -482,15 +496,14 @@ ajaxify.widgets = { render: render };
|
|||||||
}());
|
}());
|
||||||
|
|
||||||
$(document).ready(function () {
|
$(document).ready(function () {
|
||||||
$(window).on('popstate', function (ev) {
|
window.addEventListener('popstate', (ev) => {
|
||||||
ev = ev.originalEvent;
|
|
||||||
|
|
||||||
if (ev !== null && ev.state) {
|
if (ev !== null && ev.state) {
|
||||||
if (ev.state.url === null && ev.state.returnPath !== undefined) {
|
if (ev.state.url === null && ev.state.returnPath !== undefined) {
|
||||||
window.history.replaceState({
|
window.history.replaceState({
|
||||||
url: ev.state.returnPath,
|
url: ev.state.returnPath,
|
||||||
}, ev.state.returnPath, config.relative_path + '/' + ev.state.returnPath);
|
}, ev.state.returnPath, config.relative_path + '/' + ev.state.returnPath);
|
||||||
} else if (ev.state.url !== undefined) {
|
} else if (ev.state.url !== undefined) {
|
||||||
|
ajaxify.handleTransientElements();
|
||||||
ajaxify.go(ev.state.url, function () {
|
ajaxify.go(ev.state.url, function () {
|
||||||
hooks.fire('action:popstate', { url: ev.state.url });
|
hooks.fire('action:popstate', { url: ev.state.url });
|
||||||
}, true);
|
}, true);
|
||||||
|
|||||||
Reference in New Issue
Block a user