A platform for community discussion. Free, open, simple.
FIX: Render breadcrumb separator from data instead of `:last-child` (#39371)
Régis Hanol9428a235072f
diff --git a/app/assets/stylesheets/common/components/d-breadcrumbs.scss b/app/assets/stylesheets/common/components/d-breadcrumbs.scssindex 9157b4dd0c0..b6c36fd5d07 100644--- a/app/assets/stylesheets/common/components/d-breadcrumbs.scss+++ b/app/assets/stylesheets/common/components/d-breadcrumbs.scss@@ -23,10 +23,4 @@}}}-- li:last-child {- .separator {- display: none;- }- }}diff --git a/frontend/discourse/app/components/d-breadcrumbs-container.gjs b/frontend/discourse/app/components/d-breadcrumbs-container.gjsindex b8b23fa472f..d1383666fb7 100644--- a/frontend/discourse/app/components/d-breadcrumbs-container.gjs+++ b/frontend/discourse/app/components/d-breadcrumbs-container.gjs@@ -27,6 +27,7 @@ export default class DBreadcrumbsContainer extends Component {"d-breadcrumbs__link"@additionalLinkClasses}}+ @isLast={{eq index this.lastItemIndex}}aria-current={{if (eq index this.lastItemIndex) "page"}}class={{concatClass "d-breadcrumbs__item" @additionalItemClasses}}/>diff --git a/frontend/discourse/app/components/d-breadcrumbs-item.gjs b/frontend/discourse/app/components/d-breadcrumbs-item.gjsindex 99a483543cc..70e79b4e26f 100644--- a/frontend/discourse/app/components/d-breadcrumbs-item.gjs+++ b/frontend/discourse/app/components/d-breadcrumbs-item.gjs@@ -33,9 +33,11 @@ export default class DBreadcrumbsItem extends Component {{{label}}</a>{{/if}}- <span class="separator">- {{~icon "angle-right"~}}- </span>+ {{#unless @isLast}}+ <span class="separator">+ {{~icon "angle-right"~}}+ </span>+ {{/unless}}</li></template>;}diff --git a/frontend/discourse/tests/integration/components/d-breadcrumbs-test.gjs b/frontend/discourse/tests/integration/components/d-breadcrumbs-test.gjsindex 85fe5eb82a2..5fcc6d5e7d9 100644--- a/frontend/discourse/tests/integration/components/d-breadcrumbs-test.gjs+++ b/frontend/discourse/tests/integration/components/d-breadcrumbs-test.gjs@@ -46,6 +46,20 @@ module(.exists();});+ test("separator is rendered on every item except the last", async function (assert) {+ await render(+ <template>+ <DBreadcrumbsContainer />+ <DBreadcrumbsItem @path="/admin" @label="Admin" />+ <DBreadcrumbsItem @path="/admin/backups" @label="Backups" />+ <DBreadcrumbsItem @path="/admin/backups/logs" @label="Logs" />+ </template>+ );++ assert.dom(".d-breadcrumbs li .separator").exists({ count: 2 });+ assert.dom(".d-breadcrumbs li:last-child .separator").doesNotExist();+ });+test("it renders multiple DBreadcrumbsContainer elements with the same DBreadcrumbsItem links", async function (assert) {await render(<template>