Skip to content

Commit

Permalink
fix: open product description tab by default when navigating between …
Browse files Browse the repository at this point in the history
…product detail pages (#1263)
  • Loading branch information
shauke committed Aug 31, 2022
1 parent b8cb49d commit 2976009
Showing 1 changed file with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ChangeDetectionStrategy, Component, OnInit } from '@angular/core';
import { Observable, map } from 'rxjs';
import { Observable, distinctUntilKeyChanged, map, tap } from 'rxjs';

import { ProductContextDisplayProperties, ProductContextFacade } from 'ish-core/facades/product-context.facade';
import { ProductView } from 'ish-core/models/product-view/product-view.model';
Expand All @@ -12,12 +12,16 @@ import { ProductView } from 'ish-core/models/product-view/product-view.model';
export class ProductDetailInfoComponent implements OnInit {
product$: Observable<ProductView>;
isVariationMaster$: Observable<boolean>;
active = 'DESCRIPTION';
active = 'DESCRIPTION'; // default product tab

constructor(private context: ProductContextFacade) {}

ngOnInit() {
this.product$ = this.context.select('product');
this.product$ = this.context.select('product').pipe(
// when routing between products reset the opened product tab to the default tab
distinctUntilKeyChanged('sku'),
tap(() => (this.active = 'DESCRIPTION'))
);
this.isVariationMaster$ = this.context.select('variationCount').pipe(map(variationCount => !!variationCount));
}

Expand Down

0 comments on commit 2976009

Please sign in to comment.