Skip to content

Commit

Permalink
Fix page not scrolling to the right section in the instructor help page.
Browse files Browse the repository at this point in the history
  • Loading branch information
nouredinelam committed Mar 19, 2023
1 parent ef0d572 commit 42ba3ee
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 10 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<div class="flex-container">
<div class="main-body col-lg-10" #helpPage>
<div class="main-body col-lg-10">
<div id={{Sections.body}}>
<h1 class="color-orange"> Help for Instructors</h1>
<div>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { DOCUMENT } from '@angular/common';
import { AfterViewInit, Component, ElementRef, Inject, ViewChild } from '@angular/core';
import { AfterViewInit, Component, Inject, ViewChild } from '@angular/core';
import { ActivatedRoute, Params } from '@angular/router';
import { PageScrollService } from 'ngx-page-scroll-core';
import { environment } from '../../../environments/environment';
Expand Down Expand Up @@ -42,7 +42,6 @@ export class InstructorHelpPageComponent implements AfterViewInit {
questionIdToExpand: string = '';
section: string = '';

@ViewChild('helpPage') bodyRef ?: ElementRef;
@ViewChild('studentsHelpSection') studentsHelpSection?: InstructorHelpStudentsSectionComponent;
@ViewChild('coursesHelpSection') coursesHelpSection?: InstructorHelpCoursesSectionComponent;
@ViewChild('sessionsHelpSection') sessionsHelpSection?: InstructorHelpSessionsSectionComponent;
Expand Down Expand Up @@ -104,13 +103,10 @@ export class InstructorHelpPageComponent implements AfterViewInit {
* Scrolls to the section passed in
*/
scroll(section: string): void {
if (this.bodyRef) {
const el: any = Array.prototype.slice
.call(this.bodyRef.nativeElement.childNodes).find((x: any) => x.id === section);
if (el) {
el.scrollIntoView();
window.scrollBy(0, -50);
}
const el: HTMLElement | null = this.document.getElementById(section);
if (el) {
const y: number = el.getBoundingClientRect().top + window.scrollY - 70;
window.scrollTo({ top: y, behavior: 'auto' });
}
}

Expand Down

0 comments on commit 42ba3ee

Please sign in to comment.