kopia lustrzana https://github.com/wagtail/wagtail
Enforce page_breadcrumbs to be expanded when there is only one item
Rather than special-casing whether the page is root or not, just check if there is only one item. If that's the case, then the user is exploring the "explorable root instance", which may be the root Page instance or the closest common ancestor where the user has permission. In this case, we don't want to show the breadcrumbs toggle/expand button (it's always expanded). This also removes the incorrectly extraneous right arrow when exploring the root instance.pull/11754/head
rodzic
8e701f46e3
commit
6612d4d151
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
{% block breadcrumbs %}
|
||||
{# breadcrumbs #}
|
||||
{% page_breadcrumbs parent_page 'wagtailadmin_explore' url_root_name='wagtailadmin_explore_root' is_expanded=parent_page.is_root %}
|
||||
{% page_breadcrumbs parent_page 'wagtailadmin_explore' url_root_name='wagtailadmin_explore_root' %}
|
||||
{% endblock %}
|
||||
|
||||
{% block actions %}
|
||||
|
|
|
|||
|
|
@ -18,21 +18,7 @@
|
|||
{% else %}
|
||||
{% url url_name page.id as breadcrumb_url %}
|
||||
{% endif %}
|
||||
{% if page.is_root %}
|
||||
<li
|
||||
class="{{ breadcrumb_item_classes }} {% if forloop.last %}w-font-bold{% endif %} {% if not is_expanded %}w-max-w-0{% endif %}"
|
||||
{% if not is_expanded %}hidden{% endif %}
|
||||
data-w-breadcrumbs-target="content"
|
||||
>
|
||||
<a
|
||||
class="{{ breadcrumb_link_classes }}"
|
||||
href="{{ breadcrumb_url }}{{ querystring_value }}"
|
||||
>
|
||||
{% trans "Root" %}
|
||||
</a>
|
||||
{% icon name="arrow-right" classname=icon_classes %}
|
||||
</li>
|
||||
{% elif forloop.last %}
|
||||
{% if forloop.last %}
|
||||
<li
|
||||
class="{{ breadcrumb_item_classes }} w-font-bold"
|
||||
{% if trailing_breadcrumb_title and not is_expanded %}hidden{% endif %}
|
||||
|
|
|
|||
|
|
@ -92,10 +92,17 @@ def page_breadcrumbs(
|
|||
if not cca:
|
||||
return {"items": Page.objects.none()}
|
||||
|
||||
return {
|
||||
"items": page.get_ancestors(inclusive=include_self)
|
||||
items = (
|
||||
page.get_ancestors(inclusive=include_self)
|
||||
.descendant_of(cca, inclusive=True)
|
||||
.specific(),
|
||||
.specific()
|
||||
)
|
||||
|
||||
if len(items) == 1:
|
||||
is_expanded = True
|
||||
|
||||
return {
|
||||
"items": items,
|
||||
"current_page": page,
|
||||
"is_expanded": is_expanded,
|
||||
"page_perms": page_perms,
|
||||
|
|
|
|||
|
|
@ -1167,7 +1167,7 @@ class TestExplorablePageVisibility(WagtailTestUtils, TestCase):
|
|||
# When Josh is viewing his visible root page, he should the page title as a non-hidden, single-item breadcrumb.
|
||||
expected = """
|
||||
<li
|
||||
class="w-h-full w-flex w-items-center w-overflow-hidden w-transition w-duration-300 w-whitespace-nowrap w-flex-shrink-0 w-font-bold">
|
||||
class="w-h-full w-flex w-items-center w-overflow-hidden w-transition w-duration-300 w-whitespace-nowrap w-flex-shrink-0 w-font-bold" data-w-breadcrumbs-target="content">
|
||||
<a class="w-flex w-items-center w-text-text-label w-pr-0.5 w-text-14 w-no-underline w-outline-offset-inside w-border-b w-border-b-2 w-border-transparent w-box-content hover:w-border-current hover:w-text-text-label"
|
||||
href="/admin/pages/4/">
|
||||
Welcome to example.com!
|
||||
|
|
|
|||
Ładowanie…
Reference in New Issue