mirror of
https://github.com/unraid/webgui.git
synced 2026-01-06 01:29:54 -06:00
Merge pull request #2418 from Squidly271/Feat/FocusFunc
Feat: Support Focus on page tabs
This commit is contained in:
@@ -19,6 +19,9 @@
|
||||
aria-controls="<?= $tabId ?>-panel"
|
||||
tabindex="<?= $i === 0 ? '0' : '-1' ?>"
|
||||
aria-selected="<?= $i === 0 ? 'true' : 'false' ?>"
|
||||
<? if ( isset($page['Focus']) ): ?>
|
||||
data-focus="<?= htmlspecialchars($page['Focus'], ENT_QUOTES, 'UTF-8') ?>"
|
||||
<? endif; ?>
|
||||
>
|
||||
<?= tab_title($title, $page['root'], _var($page, 'Tag', false)) ?>
|
||||
</button>
|
||||
@@ -137,6 +140,15 @@ tabs.forEach((tab, i) => {
|
||||
});
|
||||
$.cookie(cookieName, tab.id);
|
||||
tab.focus();
|
||||
// call the focus function if it exists
|
||||
if (tab.getAttribute('data-focus') ) {
|
||||
const focusFnName = tab.getAttribute('data-focus');
|
||||
if (typeof window[focusFnName] === 'function') {
|
||||
window[focusFnName]();
|
||||
} else {
|
||||
console.error('Focus function not found: ' + focusFnName);
|
||||
}
|
||||
}
|
||||
});
|
||||
tab.addEventListener('keydown', e => {
|
||||
let idx = Array.prototype.indexOf.call(tabs, document.activeElement);
|
||||
|
||||
Reference in New Issue
Block a user