Skip to content

Refactor KBreadcrumbs to utilize KListWithOverflow #693

@MisRob

Description

@MisRob

This issue is not open for contribution. Visit Contributing guidelines to learn about the contributing process and how to find suitable issues.

In times when KListWithOverflow component didn't yet exist, we used the "duplicate markup" technique in the KBreadcrumbs component to achieve their overflow behavior when breadcrumb items were collapsed to the dropdown menu on the left:

breadcrumbs

The duplicate markup technique is based on keeping a hidden copy of visible breadcrumbs (breadcrumbs-offscreen) in the markup so that elements are available for recalculations:

<!-- This is a duplicate of breacrumbs-visible-items to help to reference sizes. -->
<div class="breadcrumbs breadcrumbs-offscreen" aria-hidden="true">
<ol class="breadcrumbs-visible-items">
<template v-for="(crumb, index) in crumbs">
<li
v-if="index !== crumbs.length - 1"
:ref="`crumb${index}`"
:key="index"
class="breadcrumbs-visible-item breadcrumbs-visible-item-notlast"
>
<KRouterLink v-if="crumb.link" :text="crumb.text" :to="crumb.link" tabindex="-1">
<template #text="{ text }">
<span class="breadcrumbs-crumb-text">{{ text }}</span>
</template>
</KRouterLink>
<span v-else>{{ crumb.text }}</span>
</li>
<li
v-else
:ref="`crumb${index}`"
:key="index"
class="breadcrumb-visible-item-last breadcrumbs-visible-item"
>
<span
class="breadcrumbs-crumb-text"
:style="{ maxWidth: lastBreadcrumbMaxWidth }"
>
{{ crumb.text }}
</span>
</li>
</template>
</ol>
</div>
</div>

Now that we have KListWithOverflow that is designed to take care of overflowing items to a menu, it would be good to remove this other implementation from KBreadcrumbs and refactor them to utilize KListWithOverflow instead.

The Value Add

Easier maintenance, development efficiency.

Guidance

Note that KListWithOverflow will likely need some updates to be able to display the button on the left side, and possibly some other adjustments so that these two components can collaborate smoothly.

Acceptance criteria

  • There are no regressions in places where KBreadcrumbs and KListWithOverflow are used:
    • Live examples on their documentation pages
    • In Kolibri and Studio

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions