Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"Notebook scrolls to heading" test fails subtly #15670

Closed
krassowski opened this issue Jan 20, 2024 · 2 comments · Fixed by #15703
Closed

"Notebook scrolls to heading" test fails subtly #15670

krassowski opened this issue Jan 20, 2024 · 2 comments · Fixed by #15703
Assignees

Comments

@krassowski
Copy link
Member

Since recent fixes in ToC this test: "Table of Contents scrolling to heading › Notebook scrolls to heading" fails by positioning the heading slightly off:

Actual Expected
image image
@krassowski krassowski added bug tag:Testing status:Needs Triage Applied to new issues that need triage labels Jan 20, 2024
@krassowski
Copy link
Member Author

krassowski commented Jan 20, 2024

This appears unrelated to recent security fixes to ToC implementation and indeed was already failing before these were merged as seen in #15375.

@krassowski
Copy link
Member Author

It is related to them after all. For context, this snapshot was updated in #15386 which changed the behaviour from aligning heading to bottom to aligning to the top (i.e. what users were expecting). However, the scrolling logic was not using the per-heading scrolling at the time (due to a bug in heading retrieval) and instead using cell scrolling fallback logic, see:

const el = headingToElement.get(heading);
if (el) {
if (this.scrollToTop) {
el.scrollIntoView({ block: 'start' });
} else {
const widgetBox = widget.content.node.getBoundingClientRect();
const elementBox = el.getBoundingClientRect();
if (
elementBox.top > widgetBox.bottom ||
elementBox.bottom < widgetBox.top
) {
el.scrollIntoView({ block: 'center' });
}
}
} else {
console.debug('scrolling to heading: using fallback strategy');
await widget.content.scrollToItem(
widget.content.activeCellIndex,
this.scrollToTop ? 'start' : undefined
);
}
};

Once a fix for GHSA-4m77-cmpx-vjc4 was merged, it also fixed the bug which was leading the execution into the fallback branch.

The cell scrolling logic aligns to the cell so it gave us a nice padding above the cell. But there may be multiple headings in a cell.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants