Skip to content

Cart form default action is to empty cart #22597

@aario

Description

@aario

Preconditions (*)

  1. Magento 2.3.1
  2. Firefox, Chrome, Safari

Steps to reproduce (*)

  1. Add a product to cart
  2. Go to cart page
  3. Edit the quantity
  4. Press enter inside quantity input box

Expected result (*)

  1. Quantity must be updated

Actual result (*)

  1. Cart gets empty

More info:

It happens in:
vendor/magento/module-checkout/view/frontend/templates/cart/form.phtml
Where there are two submit buttons in a form:

        <button type="submit"
                name="update_cart_action"
                data-cart-empty=""
                value="empty_cart"
                title="<?= $block->escapeHtml(__('Clear Shopping Cart')) ?>"
                class="action clear" id="empty_cart_button">
            <span><?= /* @escapeNotVerified */ __('Clear Shopping Cart') ?></span>
        </button>
        <button type="submit"
                name="update_cart_action"
                data-cart-item-update=""
                value="update_qty"
                title="<?= $block->escapeHtml(__('Update Shopping Cart')) ?>"
                class="action update">
            <span><?= /* @escapeNotVerified */ __('Update Shopping Cart') ?></span>
        </button>

When the Enter key is pressed inside quantity input box, the browser automatically chooses the first submit button which is to empty_cart. Order of these buttons should be reversed or a javascript added to define the default behavior when Enter key is pressed.

Additional Information (*)

FYI: This issue is only reproduced on magento 2.3.1 not in 2.3 nor in 2.2

Metadata

Metadata

Labels

Area: FrontendComponent: CheckoutEvent: dmcdindia1Fixed in 2.2.xThe issue has been fixed in 2.2 release lineIssue: Clear DescriptionGate 2 Passed. Manual verification of the issue description passedIssue: ConfirmedGate 3 Passed. Manual verification of the issue completed. Issue is confirmedIssue: Format is validGate 1 Passed. Automatic verification of issue format passedIssue: Ready for WorkGate 4. Acknowledged. Issue is added to backlog and ready for developmentReproduced on 2.3.xThe issue has been reproduced on latest 2.3 release

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions