diff --git a/marketplace-ui/src/app/app.config.ts b/marketplace-ui/src/app/app.config.ts index 5905267e0..d3d23dedb 100644 --- a/marketplace-ui/src/app/app.config.ts +++ b/marketplace-ui/src/app/app.config.ts @@ -1,6 +1,6 @@ import { HttpClient, provideHttpClient, withFetch, withInterceptors } from '@angular/common/http'; import { ApplicationConfig, importProvidersFrom, provideZoneChangeDetection } from '@angular/core'; -import { provideRouter } from '@angular/router'; +import { InMemoryScrollingFeature, InMemoryScrollingOptions, provideRouter, withInMemoryScrolling } from '@angular/router'; import { TranslateLoader, TranslateModule } from '@ngx-translate/core'; import { routes } from './app.routes'; import { MARKED_OPTIONS, MarkdownModule } from 'ngx-markdown'; @@ -8,10 +8,18 @@ import { markedOptionsFactory } from './core/configs/markdown.config'; import { httpLoaderFactory } from './core/configs/translate.config'; import { apiInterceptor } from './core/interceptors/api.interceptor'; +const scrollConfig: InMemoryScrollingOptions = { + scrollPositionRestoration: 'disabled', + anchorScrolling: 'disabled', +}; + +const inMemoryScrollingFeature: InMemoryScrollingFeature = + withInMemoryScrolling(scrollConfig); + export const appConfig: ApplicationConfig = { providers: [ provideZoneChangeDetection({ eventCoalescing: true }), - provideRouter(routes), + provideRouter(routes, inMemoryScrollingFeature), provideHttpClient(withFetch(), withInterceptors([apiInterceptor])), importProvidersFrom( TranslateModule.forRoot({ diff --git a/marketplace-ui/src/app/modules/product/product-detail/product-detail.component.ts b/marketplace-ui/src/app/modules/product/product-detail/product-detail.component.ts index 7024350df..0802fb82d 100644 --- a/marketplace-ui/src/app/modules/product/product-detail/product-detail.component.ts +++ b/marketplace-ui/src/app/modules/product/product-detail/product-detail.component.ts @@ -29,7 +29,7 @@ import { AuthService } from '../../../auth/auth.service'; import { ProductStarRatingNumberComponent } from './product-star-rating-number/product-star-rating-number.component'; import { ProductInstallationCountActionComponent } from './product-installation-count-action/product-installation-count-action.component'; import { ProductTypeIconPipe } from '../../../shared/pipes/icon.pipe'; -import { interval, Observable } from 'rxjs'; +import { Observable } from 'rxjs'; import { ProductStarRatingService } from './product-detail-feedback/product-star-rating-panel/product-star-rating.service'; import { RoutingQueryParamService } from '../../../shared/services/routing.query.param.service'; @@ -42,7 +42,6 @@ export interface DetailTab { const STORAGE_ITEM = 'activeTab'; const DEFAULT_ACTIVE_TAB = 'description'; -const SCROLL_INTERVAL = 500; @Component({ selector: 'app-product-detail', standalone: true, @@ -134,12 +133,7 @@ export class ProductDetailComponent { } scrollToTop() { - const intervalSub = interval(SCROLL_INTERVAL).subscribe(() => { - window.scrollTo({left: 0, top: 0, behavior: 'instant'}); - }); - setTimeout(() => { - intervalSub.unsubscribe(); - }, 1000); + window.scrollTo({ left: 0, top: 0, behavior: 'instant' }); } getProductById(productId: string): Observable {