Skip to content

Commit 7782b49

Browse files
committed
fix: prevent auto-scroll to install section on page load
1 parent 20eb275 commit 7782b49

1 file changed

Lines changed: 5 additions & 5 deletions

File tree

src/components/homepage/InstallSection.astro

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ type Props = {};
7070
var tabs = Array.from(document.querySelectorAll('.install-tab'));
7171
var panels = document.querySelectorAll('.install-panel');
7272

73-
function activateTab(tab) {
73+
function activateTab(tab, shouldFocus) {
7474
tabs.forEach(function (t) {
7575
t.classList.remove('active');
7676
t.setAttribute('aria-selected', 'false');
@@ -84,7 +84,7 @@ type Props = {};
8484
tab.classList.add('active');
8585
tab.setAttribute('aria-selected', 'true');
8686
tab.setAttribute('tabindex', '0');
87-
tab.focus();
87+
if (shouldFocus) tab.focus();
8888
var panelId = tab.getAttribute('aria-controls');
8989
var panel = document.getElementById(panelId);
9090
if (panel) {
@@ -97,12 +97,12 @@ type Props = {};
9797
var ua = navigator.userAgent.toLowerCase();
9898
if (ua.includes('mac') || ua.includes('linux')) {
9999
var macTab = document.getElementById('tab-macos');
100-
if (macTab) activateTab(macTab);
100+
if (macTab) activateTab(macTab, false);
101101
}
102102

103103
tabs.forEach(function (tab) {
104104
tab.addEventListener('click', function () {
105-
activateTab(tab);
105+
activateTab(tab, true);
106106
});
107107
});
108108

@@ -125,7 +125,7 @@ type Props = {};
125125
return;
126126
}
127127
e.preventDefault();
128-
activateTab(tabs[nextIndex]);
128+
activateTab(tabs[nextIndex], true);
129129
});
130130
}
131131
}

0 commit comments

Comments
 (0)