Skip to content

Commit ef14ba1

Browse files
committed
fix(#1999): fix scroll bar positioning on Windows and updateToc
1 parent d2c01b3 commit ef14ba1

File tree

3 files changed

+5
-12
lines changed

3 files changed

+5
-12
lines changed

packages/dev/docs/src/attachToToC.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
import sideNavStyles from '@adobe/spectrum-css-temp/components/sidenav/vars.css';
1414

1515
export function attachToToC() {
16+
let main = document.getElementsByTagName('main')[0];
1617
let tocLinks = document.querySelectorAll('#toc a');
1718
let headers = [];
1819
for (let link of tocLinks) {
@@ -26,7 +27,7 @@ export function attachToToC() {
2627
// this needs to be improved a little but the math hurts my head right now
2728
// right now it's impossible to select the last section if the last two heights combined are smaller than the viewport height
2829
headers.some((header, i) => {
29-
if ((header.header.offsetTop + header.header.getBoundingClientRect().height) > document.documentElement.scrollTop) {
30+
if ((header.header.offsetTop + header.header.getBoundingClientRect().height) > main.scrollTop + main.offsetTop) {
3031
let currentSelection = document.querySelectorAll(`#toc .${sideNavStyles['is-selected']}`);
3132
if (currentSelection) {
3233
currentSelection.forEach(node => {
@@ -47,5 +48,5 @@ export function attachToToC() {
4748

4849
updateToc();
4950

50-
document.addEventListener('scroll', updateToc);
51+
main.addEventListener('scroll', updateToc);
5152
}

packages/dev/docs/src/docs.css

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -295,8 +295,7 @@ html, body {
295295
main {
296296
margin-top: var(--spectrum-global-dimension-size-550);
297297
margin-left: 256px;
298-
margin-right: 180px;
299-
padding: 0 52px;
298+
padding: 0 244px 0 52px;
300299
box-sizing: border-box;
301300
display: flex;
302301
height: calc(100vh - var(--spectrum-global-dimension-size-550));
@@ -738,13 +737,6 @@ h2.sectionHeader {
738737
}
739738
}
740739

741-
@media (max-width: 1200px) {
742-
/* Hide the table of contents */
743-
main {
744-
margin-right: 0;
745-
}
746-
}
747-
748740
@define-mixin small-propTable {
749741
/* Collapse the prop table into a list with key/value pairs */
750742
.propTable {

packages/dev/docs/src/toc.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
.toc {
1414
position: fixed;
1515
top: 80px;
16-
right: 8px;
16+
right: 20px;
1717
overflow-y: auto;
1818
max-height: calc(100vh - 80px);
1919
}

0 commit comments

Comments
 (0)