Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 37 additions & 9 deletions apps/files/src/components/BreadCrumbs.vue
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,23 @@
v-bind="section"
dir="auto"
:to="section.to"
:class="{ 'is-current': section.isCurrent }"
:force-icon-text="index === 0 && fileListWidth >= 486"
:title="titleForSection(index, section)"
:aria-description="ariaForSection(section)"
@click.native="onClick(section.to)"
:aria-current="section.isCurrent ? 'page' : null"
:tabindex="section.isCurrent ? -1 : 0"
@click.native="onClickIfNotCurrent(section.to, index)"
@dragover.native="onDragOver($event, section.dir)"
@drop="onDrop($event, section.dir)">
<template v-if="index === 0" #icon>
<NcIconSvgWrapper
:size="20"
:svg="viewIcon" />
:size="20"
:svg="viewIcon" />
</template>
</NcBreadcrumb>


<!-- Forward the actions slot -->
<template #actions>
<slot name="actions" />
Expand Down Expand Up @@ -110,13 +114,15 @@ export default defineComponent({
return this.dirs.map((dir: string, index: number) => {
const source = this.getFileSourceFromPath(dir)
const node: Node | undefined = source ? this.getNodeFromSource(source) : undefined
const isCurrent = index === this.dirs.length - 1
return {
dir,
exact: true,
name: this.getDirDisplayName(dir),
to: this.getTo(dir, node),
// disable drop on current directory
disableDrop: index === this.dirs.length - 1,
dir,
exact: true,
name: this.getDirDisplayName(dir),
to: isCurrent ? undefined : this.getTo(dir, node),
// disable drop on current directory
disableDrop: isCurrent,
isCurrent,
}
})
},
Expand Down Expand Up @@ -147,6 +153,14 @@ export default defineComponent({
},

methods: {

// Guarded click helper — prevents navigation/click for the current (last) breadcrumb
onClickIfNotCurrent(to, index) {
// if sections isn't defined for some reason, fallback to not navigating
if (!this.sections || index === this.sections.length - 1) return
this.onClick(to)
},

getNodeFromSource(source: FileSource): Node | undefined {
return this.filesStore.getNode(source)
},
Expand Down Expand Up @@ -270,6 +284,9 @@ export default defineComponent({
},

titleForSection(index, section) {
if (section.isCurrent) {
return t('files', 'Current directory')
}
if (section?.to?.query?.dir === this.$route.query.dir) {
return t('files', 'Reload current directory')
} else if (index === 0) {
Expand Down Expand Up @@ -304,8 +321,19 @@ export default defineComponent({
a {
cursor: pointer !important;
}

/* When the breadcrumb item is the current one, make it non-interactive & not look like a link */
.is-current {
cursor: default !important;
}
.is-current a {
pointer-events: none !important;
text-decoration: none !important;
cursor: default !important;
}
}


&--with-progress {
flex-direction: column !important;
align-items: flex-start !important;
Expand Down