Skip to content

Commit

Permalink
Public search scroll to result
Browse files Browse the repository at this point in the history
  • Loading branch information
urmikgov committed Mar 6, 2024
1 parent ba6e6c3 commit eeb8372
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -127,15 +127,15 @@ <h3>Search by one or more of the following fields:</h3>

<div class="button-controls">
<button type="button" mat-stroked-button color="accent" (click)="onClear()">Clear</button>
<button type="submit" mat-flat-button color="primary" [disabled]="formEmpty || !searchForm.valid">Search</button>
<button type="submit" mat-flat-button color="primary" [disabled]="formEmpty || !searchForm.valid || isLoading">Search</button>
</div>
</form>

<div *ngIf="isLoading && searchResultsHidden" class="center">
<mat-spinner></mat-spinner>
</div>
<div class="search-fields-wrapper search-result-wrapper" *ngIf="!searchResultsHidden">
<h3 class="search-title">Search Results</h3>
<h3 class="search-title" id="searchResults">Search Results</h3>
<div *ngIf="isLoading && !searchResultsHidden" class="center">
<mat-spinner></mat-spinner>
</div>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Component, HostListener, OnDestroy, OnInit, ViewChild } from '@angular/core';
import { Component, ElementRef, HostListener, OnDestroy, OnInit, ViewChild } from '@angular/core';
import { FormControl, FormGroup } from '@angular/forms';
import { MatAutocompleteSelectedEvent } from '@angular/material/autocomplete';
import { MatPaginator } from '@angular/material/paginator';
Expand Down Expand Up @@ -128,7 +128,8 @@ export class PublicSearchComponent implements OnInit, OnDestroy {
private codeService: CodeService,
private statusService: StatusService,
private toastService: ToastService,
private titleService: Title
private titleService: Title,
private elementRef: ElementRef,
) {
this.titleService.setTitle('ALC Portal | Public Search');
}
Expand Down Expand Up @@ -193,6 +194,14 @@ export class PublicSearchComponent implements OnInit, OnDestroy {
sessionStorage.setItem(SEARCH_SESSION_STORAGE_KEY, searchDto);

this.isLoading = true;
const element = this.elementRef.nativeElement.querySelector(`#${CSS.escape('searchResults')}`);
if (element) {
element.scrollIntoView({
behavior: 'smooth',
block: 'start',
inline: 'start',
});
}
const result = await this.searchService.search(searchParams);
this.searchResultsHidden = false;
this.isLoading = false;
Expand Down

0 comments on commit eeb8372

Please sign in to comment.