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 = (
6464 }
6565
6666 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+ }
6880 }
6981
7082 if ( event . key === ESCAPE_KEY ) {
Original file line number Diff line number Diff line change @@ -38,6 +38,8 @@ export const cart = {
3838 promoCode : '#promo-code' ,
3939 deleteLinkAction : 'delete-from-cart' ,
4040 productQuantity : '.cart__items .js-quantity-button' ,
41+ productItem : '.cart__item' ,
42+ removeFromCartLink : '.remove-from-cart' ,
4143} ;
4244
4345export const blockcart = {
You can’t perform that action at this time.
0 commit comments