Early Bird Registration for DrupalCon Portland 2024 is open! Register by 23:59 PST on 31 March 2024, to get $100 off your ticket.
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.
Comment | File | Size | Author |
---|---|---|---|
uc_ajax_cart_qty_enter.patch | 686 bytes | serenecloud |
Comments
Comment #1
stewart.adam CreditAttribution: stewart.adam commentedThe 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
Comment #2
serenecloud CreditAttribution: serenecloud commentedWe 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.
Comment #3
stewart.adam CreditAttribution: stewart.adam commentedCouldn't reproduce with Safari but confirmed using Chrome, will look into this.
Comment #4
stewart.adam CreditAttribution: stewart.adam commentedTagging for 6.x-2.2 blocker.
Comment #5
stewart.adam CreditAttribution: stewart.adam commentedCommitted to latest git, should appear in dev within 24h. Thank you again for the patch and clear explanation on how to reproduce the bug.
Comment #7
Jawi CreditAttribution: Jawi commentedusing latest dev version. For d7 this issue still occurs!