summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorantoliny0919 <antoliny0919@gmail.com>2025-07-29 18:03:52 +0900
committerSarah Boyce <42296566+sarahboyce@users.noreply.github.com>2025-07-30 15:36:56 +0200
commit792ca148a2d6da6cf0778f6a866c899208ab94f9 (patch)
tree9c7da74340775736c19a7caf6680173a4440a334
parent94c2f3b99364bcf2d6d6b4afa8e995bd9d61ed0a (diff)
Fixed #36528, Refs #34917 -- Removed role="button" from object-tools links.
Regression in 849f8307a5bb33465252d0891a9b2c47dde65889. In order to prevent underlines on links styled like buttons, role="button" was added. This has been removed and the style updated to reflect that these are links.
-rw-r--r--django/contrib/admin/static/admin/css/base.css3
-rw-r--r--django/contrib/admin/templates/admin/change_form_object_tools.html2
-rw-r--r--django/contrib/admin/templates/admin/change_list_object_tools.html2
-rw-r--r--tests/admin_views/tests.py32
4 files changed, 34 insertions, 5 deletions
diff --git a/django/contrib/admin/static/admin/css/base.css b/django/contrib/admin/static/admin/css/base.css
index 082dafc141..0668d59b29 100644
--- a/django/contrib/admin/static/admin/css/base.css
+++ b/django/contrib/admin/static/admin/css/base.css
@@ -129,7 +129,8 @@ a:not(
[role="button"],
#header a,
#nav-sidebar a,
- #content-main.app-list a
+ #content-main.app-list a,
+ .object-tools a,
) {
text-decoration: underline;
}
diff --git a/django/contrib/admin/templates/admin/change_form_object_tools.html b/django/contrib/admin/templates/admin/change_form_object_tools.html
index 2ab2b541e7..067ae83761 100644
--- a/django/contrib/admin/templates/admin/change_form_object_tools.html
+++ b/django/contrib/admin/templates/admin/change_form_object_tools.html
@@ -2,7 +2,7 @@
{% block object-tools-items %}
<li>
{% url opts|admin_urlname:'history' original.pk|admin_urlquote as history_url %}
- <a role="button" href="{% add_preserved_filters history_url %}" class="historylink">{% translate "History" %}</a>
+ <a href="{% add_preserved_filters history_url %}" class="historylink">{% translate "History" %}</a>
</li>
{% if has_absolute_url %}<li><a href="{{ absolute_url }}" class="viewsitelink">{% translate "View on site" %}</a></li>{% endif %}
{% endblock %}
diff --git a/django/contrib/admin/templates/admin/change_list_object_tools.html b/django/contrib/admin/templates/admin/change_list_object_tools.html
index 35bff31fb7..11cc6fa4ba 100644
--- a/django/contrib/admin/templates/admin/change_list_object_tools.html
+++ b/django/contrib/admin/templates/admin/change_list_object_tools.html
@@ -4,7 +4,7 @@
{% if has_add_permission %}
<li>
{% url cl.opts|admin_urlname:'add' as add_url %}
- <a role="button" href="{% add_preserved_filters add_url is_popup to_field %}" class="addlink">
+ <a href="{% add_preserved_filters add_url is_popup to_field %}" class="addlink">
{% blocktranslate with cl.opts.verbose_name as name %}Add {{ name }}{% endblocktranslate %}
</a>
</li>
diff --git a/tests/admin_views/tests.py b/tests/admin_views/tests.py
index 65241becc0..26fdacfa00 100644
--- a/tests/admin_views/tests.py
+++ b/tests/admin_views/tests.py
@@ -4086,7 +4086,7 @@ class AdminViewStringPrimaryKeyTest(TestCase):
)
self.assertContains(
response,
- '<a role="button" href="%s" class="historylink"' % escape(expected_link),
+ '<a href="%s" class="historylink"' % escape(expected_link),
)
def test_redirect_on_add_view_continue_button(self):
@@ -6957,6 +6957,34 @@ class SeleniumTests(AdminSeleniumTestCase):
save_button.click()
@screenshot_cases(["desktop_size", "mobile_size", "rtl", "dark", "high_contrast"])
+ def test_object_tools(self):
+ from selenium.webdriver.common.by import By
+
+ state = State.objects.create(name="Korea")
+ city = City.objects.create(state=state, name="Gwangju")
+ self.admin_login(
+ username="super", password="secret", login_url=reverse("admin:index")
+ )
+ self.selenium.get(
+ self.live_server_url + reverse("admin:admin_views_city_changelist")
+ )
+ object_tools = self.selenium.find_elements(
+ By.CSS_SELECTOR, "ul.object-tools li a"
+ )
+ self.assertEqual(len(object_tools), 1)
+ self.take_screenshot("changelist")
+
+ self.selenium.get(
+ self.live_server_url
+ + reverse("admin:admin_views_city_change", args=(city.pk,))
+ )
+ object_tools = self.selenium.find_elements(
+ By.CSS_SELECTOR, "ul.object-tools li a"
+ )
+ self.assertEqual(len(object_tools), 2)
+ self.take_screenshot("changeform")
+
+ @screenshot_cases(["desktop_size", "mobile_size", "rtl", "dark", "high_contrast"])
def test_long_header_with_object_tools_layout(self):
from selenium.webdriver.common.by import By
@@ -8415,7 +8443,7 @@ class AdminKeepChangeListFiltersTests(TestCase):
# Check the history link.
history_link = re.search(
- '<a role="button" href="(.*?)" class="historylink">History</a>',
+ '<a href="(.*?)" class="historylink">History</a>',
response.text,
)
self.assertURLEqual(history_link[1], self.get_history_url())