1
0
mirror of https://github.com/django/django.git synced 2025-08-21 01:09:13 +00:00

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.
This commit is contained in:
antoliny0919 2025-07-29 18:03:52 +09:00 committed by Sarah Boyce
parent 94c2f3b993
commit 792ca148a2
4 changed files with 34 additions and 5 deletions

View File

@ -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;
}

View File

@ -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 %}

View File

@ -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>

View File

@ -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):
@ -6956,6 +6956,34 @@ class SeleniumTests(AdminSeleniumTestCase):
with self.wait_page_loaded():
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())