Skip to content

Commit

Permalink
fix: reset product quantity input field when switching products
Browse files Browse the repository at this point in the history
  • Loading branch information
Eisie96 committed Jan 10, 2023
1 parent 399bbc9 commit 72744de
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/app/core/facades/product-context.facade.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { BehaviorSubject, Observable, combineLatest, race } from 'rxjs';
import {
debounceTime,
distinctUntilChanged,
distinctUntilKeyChanged,
filter,
first,
map,
Expand Down Expand Up @@ -259,6 +260,16 @@ export class ProductContextFacade extends RxState<ProductContext> implements OnD
(state, minOrderQuantity) => (state.quantity ??= minOrderQuantity)
);

this.connect(
'quantity',
this.select('product').pipe(
whenTruthy(),
distinctUntilKeyChanged('sku'),
map(p => p.minOrderQuantity),
skip(1)
)
);

this.connect(
'quantity',
this.select('children').pipe(
Expand Down

0 comments on commit 72744de

Please sign in to comment.