Foxy Forum Status

We're no longer responding to questions via our forum, but we will keep it up for historical reasons. If you can't find the answer you're looking for, please visit our knowledge base or contact us. If there's enough interest in the future, we may bring the forum back.

form field autofocus on checkout

saint_malosaint_malo Member
in Help edited October 2016
Hi all,

So sorry for the noob question - hopefully this will be a quick one...

When ever I interact with the cart (on the checkout page), for example change the quantity of a product, the page automatically focuses on the first form field below the cart.

I can see the logic here, but how can I turn this off? Smells like some javascript, but don't know where to look - i've removed "autofocus" from the email field, however I have some custom fields above the email field with no autofocus on the input fields, and they still seem to highlight first after an interaction with the cart!

I could probably solve this with some CSS - but not sure that is the best way to go about it...

Hope my post made sense!
  • fc_adamfc_adam FoxyCart Team

    Good question, not a noob one at all.

    On the checkout we keep track of what the last field to have focus was. On page load, that defaults to the first inputs within the checkout field (which is usually the email) - but as you interact with the form we keep track of where you were last focused. Then with any re-rendering of the Twig templates that happen dynamically on the page, that focus is maintained.

    We don't keep track of focus to the cart on the checkout though - so if you click on one of the quantity inputs to give it focus and change the value - the last focused input is still whatever had focus before interacting with the quantity input. Then on change, that focus returns to the item.

    So for example - if you give focus to the first name field, then change the quantity, you'll see the focus return to where you were up to on the checkout, being the first name field.

    This is managed through javascript, and unfortunately I'm not sure it's something that would be easily adjusted.
  • Thanks for clarifying @fc_adam - I can work around this.
Sign In or Register to comment.