Problem/Motivation
HTML forms in Drupal may be submitted using the Enter key (or the "Go" key on iPad on-screen keyboard visible when filling out form text fields). The commerce cart form contains text fields that allow you to update the quantity field before checkout. Additionally, there is a convenience ajax that recalculates the total price, and the subtotal of the cart, based on changes you make. This calculation is made on the fly but only triggered by losing focus of the text field. This means the user must specifically click (with a mouse) outside of the form text field (or on keyboard navigation, press the tab key). If the user changes the value, and hits the "Enter" key, the form is submitted with the original value of the field, not the new value just entered.
This issue was originally detected on an iPad due to the common workflow that makes use of the on-screen keyboard's "Go" button to submit forms. However, this issue is also confirmed to be a fundamental problem exhibited on desktops as well, if you use the "enter" key to submit a form without changing the focus from the quantity field.
On an iPad, there are only two ways to ensure the right quantity value is submitted, neither of which are the most natural workflow for iPad:
a) use the Previous/Next buttons (in the top-left of the on-screen keyboard) to navigate away from the edited quantity field, to the next form element, thus triggering the recalculation, or
b) use the "hide keyboard" button (in the bottom-right of the on-screen keyboard) to hide the keyboard, and click the form submit button on the page itself.
Proposed resolution
There may be a couple solutions to this, I'm not sure which one would be best, but what is absolutely necessary would be to listen for the form submit from Enter key (or "Go" button on iPad) and ensure the quantity field of the last quantity field that had focus uses the correct value to submit the form.
Here's an example code of how we might override the default submit handler:
http://stackoverflow.com/questions/2794017/disable-form-submission-via-e...
Remaining tasks
- Write tests.
- Write patch.
- Review patch.
User interface changes
None.
API changes
None.
Comments
Comment #1
rszrama commentedThis behavior you're describing doesn't sound like core Drupal Commerce:
"... there is a convenience ajax that recalculates the total price, and the subtotal of the cart, based on changes you make. This calculation is made on the fly but only triggered by losing focus of the text field."
Can you determine what contributed module is adding the recalculation behavior and move it to that queue?
Comment #2
jwilson3Ryan,
#facepalm. This turned out to be a custom component we built on top of Commerce :P
Will ask our devs first next time. Extremely embarrassed and sorry for wasting your time like this.
Comment #3
rszrama commentedlol No worries. Thanks for updating the issue. : )
I know it really does help at times to have someone rule out a piece of the puzzle - I've had my fair share of difficulties writing integrations before. ; )