From 729266c6f29c7a0677b24926a86a767ef3078b26 Mon Sep 17 00:00:00 2001 From: Tom Carrick Date: Thu, 23 Nov 2023 18:26:01 +0100 Subject: [PATCH] Fixed #34982 -- Fixed admin's read-only password widget and help texts alignment for tablet screen size. Co-authored-by: Sarah Boyce <42296566+sarahboyce@users.noreply.github.com> --- .../contrib/admin/static/admin/css/forms.css | 2 +- .../admin/static/admin/css/responsive.css | 1 + .../admin/static/admin/css/widgets.css | 1 + docs/releases/4.2.8.txt | 4 ++++ tests/admin_views/tests.py | 23 +++++++++++++++++-- 5 files changed, 28 insertions(+), 3 deletions(-) diff --git a/django/contrib/admin/static/admin/css/forms.css b/django/contrib/admin/static/admin/css/forms.css index e45abe1c07e9..6cfe9da11949 100644 --- a/django/contrib/admin/static/admin/css/forms.css +++ b/django/contrib/admin/static/admin/css/forms.css @@ -24,7 +24,6 @@ form .form-row p { .flex-container { display: flex; - flex-wrap: wrap; } .form-multiline > div { @@ -78,6 +77,7 @@ form ul.inline li { .aligned label { display: block; padding: 4px 10px 0 0; + min-width: 160px; width: 160px; word-wrap: break-word; line-height: 1; diff --git a/django/contrib/admin/static/admin/css/responsive.css b/django/contrib/admin/static/admin/css/responsive.css index f58f1e552d2a..bbcfd3929ecb 100644 --- a/django/contrib/admin/static/admin/css/responsive.css +++ b/django/contrib/admin/static/admin/css/responsive.css @@ -588,6 +588,7 @@ input[type="submit"], button { .aligned label { width: 100%; + min-width: auto; padding: 0 0 10px; } diff --git a/django/contrib/admin/static/admin/css/widgets.css b/django/contrib/admin/static/admin/css/widgets.css index f8d888ed5146..3ab5fb1eb296 100644 --- a/django/contrib/admin/static/admin/css/widgets.css +++ b/django/contrib/admin/static/admin/css/widgets.css @@ -69,6 +69,7 @@ padding: 0; overflow: hidden; line-height: 1; + min-width: auto; } .selector .selector-available input, diff --git a/docs/releases/4.2.8.txt b/docs/releases/4.2.8.txt index 44d80060b5ac..0550e026bb64 100644 --- a/docs/releases/4.2.8.txt +++ b/docs/releases/4.2.8.txt @@ -31,3 +31,7 @@ Bugfixes * Fixed a regression in Django 4.2 that caused a crash of querysets with aggregations on MariaDB when the ``ONLY_FULL_GROUP_BY`` SQL mode was enabled (:ticket:`34992`). + +* Fixed a regression in Django 4.2 where the admin's read-only password widget + and some help texts were incorrectly aligned at tablet widths + (:ticket:`34982`). diff --git a/tests/admin_views/tests.py b/tests/admin_views/tests.py index ecb177e47f4d..c87779766732 100644 --- a/tests/admin_views/tests.py +++ b/tests/admin_views/tests.py @@ -5754,6 +5754,7 @@ def test_prepopulated_fields(self): and with stacked and tabular inlines. Refs #13068, #9264, #9983, #9784. """ + from selenium.webdriver import ActionChains from selenium.webdriver.common.by import By self.admin_login( @@ -5766,6 +5767,8 @@ def test_prepopulated_fields(self): # Main form ---------------------------------------------------------- self.selenium.find_element(By.ID, "id_pubdate").send_keys("2012-02-18") + status = self.selenium.find_element(By.ID, "id_status") + ActionChains(self.selenium).move_to_element(status).click(status).perform() self.select_option("#id_status", "option two") self.selenium.find_element(By.ID, "id_name").send_keys( " the mAin nÀMë and it's awεšomeıııİ" @@ -5784,6 +5787,10 @@ def test_prepopulated_fields(self): self.selenium.find_element( By.ID, "id_relatedprepopulated_set-0-pubdate" ).send_keys("2011-12-17") + status = self.selenium.find_element( + By.ID, "id_relatedprepopulated_set-0-status" + ) + ActionChains(self.selenium).move_to_element(status).click(status).perform() self.select_option("#id_relatedprepopulated_set-0-status", "option one") self.selenium.find_element( By.ID, "id_relatedprepopulated_set-0-name" @@ -5815,6 +5822,10 @@ def test_prepopulated_fields(self): self.selenium.find_element( By.ID, "id_relatedprepopulated_set-1-pubdate" ).send_keys("1999-01-25") + status = self.selenium.find_element( + By.ID, "id_relatedprepopulated_set-1-status" + ) + ActionChains(self.selenium).move_to_element(status).click(status).perform() self.select_option("#id_relatedprepopulated_set-1-status", "option two") self.selenium.find_element( By.ID, "id_relatedprepopulated_set-1-name" @@ -5838,10 +5849,10 @@ def test_prepopulated_fields(self): # Tabular inlines ---------------------------------------------------- # Initial inline - element = self.selenium.find_element( + status = self.selenium.find_element( By.ID, "id_relatedprepopulated_set-2-0-status" ) - self.selenium.execute_script("window.scrollTo(0, %s);" % element.location["y"]) + ActionChains(self.selenium).move_to_element(status).click(status).perform() self.selenium.find_element( By.ID, "id_relatedprepopulated_set-2-0-pubdate" ).send_keys("1234-12-07") @@ -5872,6 +5883,10 @@ def test_prepopulated_fields(self): self.selenium.find_element( By.ID, "id_relatedprepopulated_set-2-1-pubdate" ).send_keys("1981-08-22") + status = self.selenium.find_element( + By.ID, "id_relatedprepopulated_set-2-1-status" + ) + ActionChains(self.selenium).move_to_element(status).click(status).perform() self.select_option("#id_relatedprepopulated_set-2-1-status", "option one") self.selenium.find_element( By.ID, "id_relatedprepopulated_set-2-1-name" @@ -5898,6 +5913,8 @@ def test_prepopulated_fields(self): # Initial inline. row_id = "id_relatedprepopulated_set-4-0-" self.selenium.find_element(By.ID, f"{row_id}pubdate").send_keys("2011-12-12") + status = self.selenium.find_element(By.ID, f"{row_id}status") + ActionChains(self.selenium).move_to_element(status).click(status).perform() self.select_option(f"#{row_id}status", "option one") self.selenium.find_element(By.ID, f"{row_id}name").send_keys( " sŤāÇkeð inline ! " @@ -5917,6 +5934,8 @@ def test_prepopulated_fields(self): )[3].click() row_id = "id_relatedprepopulated_set-4-1-" self.selenium.find_element(By.ID, f"{row_id}pubdate").send_keys("1999-01-20") + status = self.selenium.find_element(By.ID, f"{row_id}status") + ActionChains(self.selenium).move_to_element(status).click(status).perform() self.select_option(f"#{row_id}status", "option two") self.selenium.find_element(By.ID, f"{row_id}name").send_keys( " now you haVe anöther sŤāÇkeð inline with a very loooong "