From 7d583a52b904eb693a744210a9ab3d1af8547eb1 Mon Sep 17 00:00:00 2001 From: kevinhowbrook Date: Wed, 13 Mar 2019 12:19:10 +0000 Subject: [PATCH] When two date fields are in the same form, chrome ignores multiple autocomplete=off values. (#5136) --- CHANGELOG.txt | 1 + docs/releases/2.5.rst | 1 + wagtail/admin/tests/test_widgets.py | 4 ++-- wagtail/admin/widgets.py | 6 +++--- wagtail/core/tests/test_blocks.py | 6 +++--- 5 files changed, 10 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.txt b/CHANGELOG.txt index 456e734363..a54822c93a 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -38,6 +38,7 @@ Changelog * Fix: Inform user when moving a page from one parent to another where there is an already existing page with the same slug (Casper Timmers) * Fix: User add/edit forms now support form widgets with JS/CSS media (Damian Grinwis) * Fix: Rich text processing now preserves non-breaking spaces instead of converting them to normal spaces (Wesley van Lee) + * Fix: Prevent autocomplete dropdowns from appearing over date choosers on Chrome (Kevin Howbrook) 2.4 (19.12.2018) diff --git a/docs/releases/2.5.rst b/docs/releases/2.5.rst index fe40e469fb..ec0c234261 100644 --- a/docs/releases/2.5.rst +++ b/docs/releases/2.5.rst @@ -54,6 +54,7 @@ Bug fixes * Inform user when moving a page from one parent to another where there is an already existing page with the same slug (Casper Timmers) * User add/edit forms now support form widgets with JS/CSS media (Damian Grinwis) * Rich text processing now preserves non-breaking spaces instead of converting them to normal spaces (Wesley van Lee) + * Prevent autocomplete dropdowns from appearing over date choosers on Chrome (Kevin Howbrook) Upgrade considerations diff --git a/wagtail/admin/tests/test_widgets.py b/wagtail/admin/tests/test_widgets.py index a0d14a7aca..aca71d2830 100644 --- a/wagtail/admin/tests/test_widgets.py +++ b/wagtail/admin/tests/test_widgets.py @@ -94,7 +94,7 @@ class TestAdminDateInput(TestCase): html = widget.render('test', None, attrs={'id': 'test-id'}) - self.assertInHTML('', html) + self.assertInHTML('', html) # we should see the JS initialiser code: # initDateChooser("test-id", {"dayOfWeekStart": 0, "format": "Y-m-d"}); @@ -130,7 +130,7 @@ class TestAdminDateTimeInput(TestCase): html = widget.render('test', None, attrs={'id': 'test-id'}) - self.assertInHTML('', html) + self.assertInHTML('', html) # we should see the JS initialiser code: # initDateTimeChooser("test-id", {"dayOfWeekStart": 0, "format": "Y-m-d H:i"}); diff --git a/wagtail/admin/widgets.py b/wagtail/admin/widgets.py index 3b0b8acfae..794cae4305 100644 --- a/wagtail/admin/widgets.py +++ b/wagtail/admin/widgets.py @@ -38,7 +38,7 @@ class AdminDateInput(widgets.DateInput): template_name = 'wagtailadmin/widgets/date_input.html' def __init__(self, attrs=None, format=None): - default_attrs = {'autocomplete': 'off'} + default_attrs = {'autocomplete': 'new-date'} fmt = format if attrs: default_attrs.update(attrs) @@ -63,7 +63,7 @@ class AdminTimeInput(widgets.TimeInput): template_name = 'wagtailadmin/widgets/time_input.html' def __init__(self, attrs=None, format='%H:%M'): - default_attrs = {'autocomplete': 'off'} + default_attrs = {'autocomplete': 'new-time'} if attrs: default_attrs.update(attrs) super().__init__(attrs=default_attrs, format=format) @@ -73,7 +73,7 @@ class AdminDateTimeInput(widgets.DateTimeInput): template_name = 'wagtailadmin/widgets/datetime_input.html' def __init__(self, attrs=None, format=None): - default_attrs = {'autocomplete': 'off'} + default_attrs = {'autocomplete': 'new-date-time'} fmt = format if attrs: default_attrs.update(attrs) diff --git a/wagtail/core/tests/test_blocks.py b/wagtail/core/tests/test_blocks.py index 2dafc6086c..a708d9065f 100644 --- a/wagtail/core/tests/test_blocks.py +++ b/wagtail/core/tests/test_blocks.py @@ -2929,7 +2929,7 @@ class TestDateBlock(TestCase): self.assertIn('"format": "Y-m-d"', result) self.assertInHTML( - '', + '', result ) @@ -2942,7 +2942,7 @@ class TestDateBlock(TestCase): self.assertIn('"dayOfWeekStart": 0', result) self.assertIn('"format": "d.m.Y"', result) self.assertInHTML( - '', + '', result ) @@ -2958,7 +2958,7 @@ class TestDateTimeBlock(TestCase): result ) self.assertInHTML( - '', + '', result )