As far as I could see in the Javascript there's nothing that explicitly handles the case where a user changes a quantity and strikes the Enter key. This means in our case, Enter is submitting the form and when combined with clicking Update cart, then changing the value and pressing Enter we have seen the callback load in the browser window, rather than the form realoading in place.

My patch adds a keypress .bind to the input that triggers triggerCartSubmit() when the pressed key is Enter, which has fixed this issue for us - I hope it's useful to others.

CommentFileSizeAuthor
uc_ajax_cart_qty_enter.patch686 bytesserenecloud
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

stewart.adam’s picture

The patch looks OK, but I can't seem to reproduce the issue you're describing. When pressing Enter or clicking the Update Cart button the cart disables itself and submits and only because available for interaction with the user again after the callback is completed, so the user never gets a chance to submit the form while it is executing the callback.

What browser and version of Ubercart did you experience this issue on? If I've understood correctly, following steps reproduced the issue on your site:
1. Add a product to the cart
2. Browse to the cart page
3. Update a qty
4. Press Enter
5. Click Update cart

serenecloud’s picture

We are running the latest Ubercart 6.x-2.7.

In order to reproduce this, I did the following:

On /admin/store/settings/uc_ajax_cart tick "Ajaxify cart page" leave "Hide update button in cart page", "Ajax support for anonymous users" and "Ajax update on page load for registered users." unticked.

1. Add am item to your cart
2. Browse to cart page
3. Update a quantity
4. Click Update cart without losing focus on the Qty input
5. Wait until the update has finished and the new quantity shows
6. Change the quantity to a new value
7. Press Enter

In my case my browser loads the path /uc_ajax_cart/show-cart-view in the browser.

stewart.adam’s picture

Status: Needs review » Active

Couldn't reproduce with Safari but confirmed using Chrome, will look into this.

stewart.adam’s picture

Issue tags: +6.x-2.2 blocker

Tagging for 6.x-2.2 blocker.

stewart.adam’s picture

Status: Active » Fixed

Committed to latest git, should appear in dev within 24h. Thank you again for the patch and clear explanation on how to reproduce the bug.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

Jawi’s picture

using latest dev version. For d7 this issue still occurs!