Updated:
function navigateToTab(tabIndex) {
document.querySelectorAll('.nav-link').forEach(tab => {
tab.classList.remove('active');
});
const tabs = document.querySelectorAll('.nav-link');
const targetTab = tabs[tabIndex];
if (!targetTab) return; // Exit if tab doesn't exist
targetTab.classList.add('active');
const targetPaneId = targetTab.getAttribute('aria-controls') ||
(targetTab.getAttribute('href') ? targetTab.getAttribute('href').substring(1) : null);
if (targetPaneId) {
const targetPane = document.getElementById(targetPaneId);
if (targetPane) {
document.querySelectorAll('.tab-pane').forEach(pane => {
pane.classList.remove('active', 'show');
});
targetPane.classList.add('active', 'show');
}
}
targetTab.focus();
}
function on_view_form_keydown(item, e) {
if (e.ctrlKey && (e.key === 'ArrowLeft' || e.key === 'ArrowRight')) {
const tabs = Array.from(document.querySelectorAll('.nav-link'));
if (tabs.length <= 1) {
e.preventDefault();
e.stopPropagation();
e.stopImmediatePropagation();
return;
}
e.preventDefault();
e.stopPropagation();
e.stopImmediatePropagation();