Skip to content

Commit f8d7235

Browse files
committed
fix: breadcrumb separator is displayed even if next breadcrumb element is not visible quasarframework#1639
1 parent aaba97f commit f8d7235

File tree

2 files changed

+29
-9
lines changed

2 files changed

+29
-9
lines changed

dev/components/components/breadcrumbs.vue

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,16 @@
66
<br>
77
If window is wide enough then labels are also displayed.
88
</p>
9+
<q-toggle v-model="first" label="first" />
10+
<q-toggle v-model="second" label="second" />
11+
<q-toggle v-model="third" label="third" />
12+
<br><br>
913
<q-breadcrumbs>
10-
<q-breadcrumbs-el label="Home" icon="home" />
11-
<q-breadcrumbs-el label="Components" icon="widgets" />
12-
<q-breadcrumbs-el label="Breadcrumbs" icon="navigation" />
14+
<q-breadcrumbs-el v-if="first" label="Home" icon="home" />
15+
<q-breadcrumbs-el v-if="second" label="Components" icon="widgets" />
16+
<q-breadcrumbs-el v-if="third" label="Breadcrumbs" icon="navigation" />
1317
</q-breadcrumbs>
18+
1419
<br><br>
1520
<q-breadcrumbs icon-separator="chevron_right" active-color="secondary" color="light">
1621
<q-breadcrumbs-el label="Home" to="/" />
@@ -35,3 +40,15 @@
3540
</div>
3641
</div>
3742
</template>
43+
44+
<script>
45+
export default {
46+
data () {
47+
return {
48+
first: true,
49+
second: true,
50+
third: true
51+
}
52+
}
53+
}
54+
</script>

src/components/breadcrumbs/QBreadcrumbs.js

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,20 +26,23 @@ export default {
2626
}
2727
},
2828
render (h) {
29+
if (!this.$slots.default) {
30+
return
31+
}
32+
2933
const
3034
child = [],
31-
length = this.$slots.default.length - 1,
35+
len = this.$slots.default.filter(c => c.tag !== void 0 && c.tag.endsWith('-QBreadcrumbsEl')).length,
3236
separator = this.$scopedSlots.separator || (() => this.separator),
3337
color = `text-${this.color}`,
3438
active = `text-${this.activeColor}`
39+
let els = 1
3540

3641
for (const i in this.$slots.default) {
3742
const comp = this.$slots.default[i]
38-
if (
39-
comp.componentOptions &&
40-
['q-breadcrumbs-el', 'QBreadcrumbsEl', 'qBreadcrumbsEl'].includes(comp.componentOptions.tag)
41-
) {
42-
const middle = i < length
43+
if (comp.tag !== void 0 && comp.tag.endsWith('-QBreadcrumbsEl')) {
44+
const middle = els < len
45+
els++
4346

4447
child.push(h('div', {
4548
'class': [ middle ? active : color, middle ? 'text-weight-bold' : 'q-breadcrumbs-last' ]

0 commit comments

Comments
 (0)