Skip to content

Commit 1f57f0f

Browse files
authored
Merge pull request #18772 from johndoknjas/fix-premature-request-clear
Only clear the scroll request when there is an active chapter.
2 parents 5fe0abf + c42f70e commit 1f57f0f

File tree

1 file changed

+9
-10
lines changed

1 file changed

+9
-10
lines changed

ui/analyse/src/study/studyChapters.ts

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -244,18 +244,17 @@ export class StudyChapterScroller {
244244

245245
scrollIfNeeded(list: HTMLElement) {
246246
if (!this.request) return;
247+
const active = list.querySelector('.active');
248+
if (!active) return;
247249
const request = this.request;
248250
this.request = undefined;
249-
const active = list.querySelector('.active');
250-
if (active) {
251-
const [c, l] = [list.getBoundingClientRect(), active.getBoundingClientRect()];
252-
if (c.top < l.top || c.bottom > l.bottom) {
253-
cancelAnimationFrame(this.rafId ?? 0);
254-
this.rafId = requestAnimationFrame(() => {
255-
scrollToInnerSelector(list, '.active', false, request);
256-
this.rafId = undefined;
257-
});
258-
}
251+
const [c, l] = [list.getBoundingClientRect(), active.getBoundingClientRect()];
252+
if (c.top < l.top || c.bottom > l.bottom) {
253+
cancelAnimationFrame(this.rafId ?? 0);
254+
this.rafId = requestAnimationFrame(() => {
255+
scrollToInnerSelector(list, '.active', false, request);
256+
this.rafId = undefined;
257+
});
259258
}
260259
}
261260
}

0 commit comments

Comments
 (0)