File tree Expand file tree Collapse file tree 2 files changed +15
-1
lines changed Expand file tree Collapse file tree 2 files changed +15
-1
lines changed Original file line number Diff line number Diff line change @@ -64,7 +64,19 @@ const useQuantityInput: Theme.QuantityInput.Function = (
64
64
}
65
65
66
66
if ( event . key === ENTER_KEY ) {
67
- updateQuantity ( qtyInputGroup , 1 ) ;
67
+ if ( qtyInput . value === '0' ) {
68
+ const targetItem = qtyInput . closest ( cartSelectorMap . productItem ) ;
69
+ const removeButton = targetItem ?. querySelector ( cartSelectorMap . removeFromCartLink ) as HTMLElement
70
+ | null ;
71
+
72
+ if ( removeButton ) {
73
+ removeButton . click ( ) ;
74
+ } else {
75
+ updateQuantity ( qtyInputGroup , 1 ) ;
76
+ }
77
+ } else {
78
+ updateQuantity ( qtyInputGroup , 1 ) ;
79
+ }
68
80
}
69
81
70
82
if ( event . key === ESCAPE_KEY ) {
Original file line number Diff line number Diff line change @@ -38,6 +38,8 @@ export const cart = {
38
38
promoCode : '#promo-code' ,
39
39
deleteLinkAction : 'delete-from-cart' ,
40
40
productQuantity : '.cart__items .js-quantity-button' ,
41
+ productItem : '.cart__item' ,
42
+ removeFromCartLink : '.remove-from-cart' ,
41
43
} ;
42
44
43
45
export const blockcart = {
You can’t perform that action at this time.
0 commit comments