Merge pull request #2418 from Squidly271/Feat/FocusFunc

Feat: Support Focus on page tabs
This commit is contained in:
tom mortensen
2025-10-14 21:05:02 -07:00
committed by GitHub

View File

@@ -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);