0
0
Fork 0

Fix sidebar and tabs on settings on small screens in admin UI (#19533)

This commit is contained in:
Eugen Rochko 2022-10-30 02:43:15 +02:00 committed by GitHub
parent 6094a916b1
commit ad83e64795
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 78 additions and 43 deletions

View file

@ -247,8 +247,31 @@ function main() {
input.readonly = oldReadOnly;
});
const toggleSidebar = () => {
const sidebar = document.querySelector('.sidebar ul');
const toggleButton = document.querySelector('.sidebar__toggle__icon');
if (sidebar.classList.contains('visible')) {
document.body.style.overflow = null;
toggleButton.setAttribute('aria-expanded', false);
} else {
document.body.style.overflow = 'hidden';
toggleButton.setAttribute('aria-expanded', true);
}
toggleButton.classList.toggle('active');
sidebar.classList.toggle('visible');
};
delegate(document, '.sidebar__toggle__icon', 'click', () => {
document.querySelector('.sidebar ul').classList.toggle('visible');
toggleSidebar();
});
delegate(document, '.sidebar__toggle__icon', 'keydown', e => {
if (e.key === ' ' || e.key === 'Enter') {
e.preventDefault();
toggleSidebar();
}
});
// Empty the honeypot fields in JS in case something like an extension