mirror of
https://ghproxy.net/https://github.com/AlxMedia/dashscroll.git
synced 2025-08-27 01:41:40 +08:00
1.0.2
This commit is contained in:
parent
c8df5a79d5
commit
bc21dce771
3 changed files with 26 additions and 21 deletions
|
@ -109,29 +109,31 @@ jQuery(document).ready(function($) {
|
|||
'button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])';
|
||||
const modal = document.querySelector('.search-trap-focus'); // select the modal by it's id
|
||||
|
||||
const firstFocusableElement = modal.querySelectorAll(focusableElements)[0]; // get first element to be focused inside modal
|
||||
const focusableContent = modal.querySelectorAll(focusableElements);
|
||||
const lastFocusableElement = focusableContent[focusableContent.length - 1]; // get last element to be focused inside modal
|
||||
if ( modal ) {
|
||||
const firstFocusableElement = modal.querySelectorAll(focusableElements)[0]; // get first element to be focused inside modal
|
||||
const focusableContent = modal.querySelectorAll(focusableElements);
|
||||
const lastFocusableElement = focusableContent[focusableContent.length - 1]; // get last element to be focused inside modal
|
||||
|
||||
|
||||
document.addEventListener('keydown', function(e) {
|
||||
let isTabPressed = e.key === 'Tab' || e.keyCode === 9;
|
||||
document.addEventListener('keydown', function(e) {
|
||||
let isTabPressed = e.key === 'Tab' || e.keyCode === 9;
|
||||
|
||||
if (!isTabPressed) {
|
||||
return;
|
||||
}
|
||||
if (!isTabPressed) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (e.shiftKey) { // if shift key pressed for shift + tab combination
|
||||
if (document.activeElement === firstFocusableElement) {
|
||||
lastFocusableElement.focus(); // add focus for the last focusable element
|
||||
e.preventDefault();
|
||||
}
|
||||
} else { // if tab key is pressed
|
||||
if (document.activeElement === lastFocusableElement) { // if focused has reached to last focusable element then focus first focusable element after pressing tab
|
||||
firstFocusableElement.focus(); // add focus for the first focusable element
|
||||
e.preventDefault();
|
||||
}
|
||||
}
|
||||
});
|
||||
if (e.shiftKey) { // if shift key pressed for shift + tab combination
|
||||
if (document.activeElement === firstFocusableElement) {
|
||||
lastFocusableElement.focus(); // add focus for the last focusable element
|
||||
e.preventDefault();
|
||||
}
|
||||
} else { // if tab key is pressed
|
||||
if (document.activeElement === lastFocusableElement) { // if focused has reached to last focusable element then focus first focusable element after pressing tab
|
||||
firstFocusableElement.focus(); // add focus for the first focusable element
|
||||
e.preventDefault();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
});
|
|
@ -81,6 +81,9 @@ Content images
|
|||
|
||||
== Changelog ==
|
||||
|
||||
= 1.0.2 - 2021-03-03 =
|
||||
* Fixed: javascript error if search button is disabled
|
||||
|
||||
= 1.0.1 - 2021-03-02 =
|
||||
* Fixed: mobile menu tabbing will enter in the menu even when it's closed
|
||||
* Fixed: add styles to focus states of menu and search
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
Theme Name: Dashscroll
|
||||
Theme URI: http://alx.media/themes/dashscroll/
|
||||
Version: 1.0.1
|
||||
Version: 1.0.2
|
||||
Requires at least: 5.0
|
||||
Requires PHP: 5.6
|
||||
Tested up to: 5.6
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue