From c18b259b274512ddedbb9b07e8615f1b99afef59 Mon Sep 17 00:00:00 2001 From: Raphael Michel Date: Tue, 13 Mar 2018 09:37:34 +0100 Subject: [PATCH] Widget: Work around a scrolling quirk in Chrome --- src/pretix/presale/forms/checkout.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/pretix/presale/forms/checkout.py b/src/pretix/presale/forms/checkout.py index 198305addb..abc4bd626a 100644 --- a/src/pretix/presale/forms/checkout.py +++ b/src/pretix/presale/forms/checkout.py @@ -26,7 +26,7 @@ class ContactForm(forms.Form): 'confirmation including a link that you need in case you want to make ' 'modifications to your order or download your ticket later.'), validators=[EmailBlacklistValidator()], - widget=forms.EmailInput(attrs={'autofocus': 'autofocus'})) + ) def __init__(self, *args, **kwargs): self.event = kwargs.pop('event') @@ -39,6 +39,12 @@ class ContactForm(forms.Form): help_text=_('Please enter the same email address again to make sure you typed it correctly.') ) + if self.request.session.get('iframe_session', False): + # There is a browser quirk in Chrome that leads to incorrect initial scrolling in iframes if there + # is an autofocus field. Who would have thought… See e.g. here: + # https://floatboxjs.com/forum/topic.php?post=8440&usebb_sid=2e116486a9ec6b7070e045aea8cded5b#post8440 + self.fields['email'].widget.attrs['autofocus'] = 'autofocus' + responses = contact_form_fields.send(self.event, request=self.request) for r, response in sorted(responses, key=lambda r: str(r[0])): for key, value in response.items():