Skip to content
This repository has been archived by the owner on Mar 6, 2024. It is now read-only.

Commit

Permalink
Error in activity reporter not visible, need to scroll to the top
Browse files Browse the repository at this point in the history
Add a scrollIntoView method for the vcd-banner-activity-reporter. This increases the visibility of success and error messages by scrolling the activity reporter banner into view.

Testing Done:
- Edited examples locally to have a page where the error/success message is not visible.
- Observed that the scrolling to the activity banner was successful.

Signed-off-by: Juliana Sica <juliana.sica@broadcom.com>
  • Loading branch information
jsica committed Dec 5, 2023
1 parent c0d4bee commit 3bdbbdb
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
1 change: 1 addition & 0 deletions projects/components/CHANGELOG.MD
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Fix ErrorBannerExampleComponent when closed with X button
### Changed
* errorMessage reset value is `null` instead of `undefined`
* Add scrollIntoView method for the vcd-banner-activity-reporter

## [15.0.1-dev.12]
### Fixed
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* SPDX-License-Identifier: BSD-2-Clause
*/

import { Component, Inject, Input } from '@angular/core';
import { Component, ElementRef, Inject, Input } from '@angular/core';
import { TranslationService } from '@vcd/i18n';
import { LazyString } from '@vcd/i18n';
import { ActivityPromiseResolver } from './activity-promise-resolver';
Expand All @@ -29,6 +29,7 @@ export class BannerActivityReporterComponent extends ActivityReporter {

constructor(
private translationService: TranslationService,
private elementRef: ElementRef,
@Inject(ActivityPromiseResolver) promiseResolver: ActivityPromiseResolver<any>
) {
super(promiseResolver);
Expand All @@ -49,6 +50,7 @@ export class BannerActivityReporterComponent extends ActivityReporter {
reportError(errorText: string): void {
this.errorText = errorText;
this.running = false;
this.scrollIntoView();
}

/**
Expand All @@ -59,6 +61,7 @@ export class BannerActivityReporterComponent extends ActivityReporter {
this.successMessage = successMessage;
}
this.running = false;
this.scrollIntoView();
}

/**
Expand All @@ -75,6 +78,13 @@ export class BannerActivityReporterComponent extends ActivityReporter {
this.successMessage = null;
}

/**
* Scroll to the banner activity reporter.
*/
private scrollIntoView(): void {
this.elementRef.nativeElement.scrollIntoView({ block: 'nearest', behavior: 'smooth' });
}

/*
* Reset the banner activity state manually.
*
Expand Down

0 comments on commit 3bdbbdb

Please sign in to comment.