From 31524d814fc7c25219d584d23caa4b04c3adc76f Mon Sep 17 00:00:00 2001 From: Vanessa Date: Thu, 16 Mar 2023 00:14:12 +0800 Subject: [PATCH] :art: fix https://github.com/siyuan-note/siyuan/issues/7675 --- app/src/protyle/breadcrumb/index.ts | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/app/src/protyle/breadcrumb/index.ts b/app/src/protyle/breadcrumb/index.ts index 05214010a..ae3c71798 100644 --- a/app/src/protyle/breadcrumb/index.ts +++ b/app/src/protyle/breadcrumb/index.ts @@ -430,7 +430,7 @@ export class Breadcrumb { `; } else { - html += ` + html += ` ${item.name} `; @@ -446,25 +446,22 @@ export class Breadcrumb { return; } let jump = false; - while (this.element.scrollHeight > 30 && !jump) { + while (this.element.scrollHeight > 30 && !jump && itemElements.length > 1) { itemElements.find((item, index) => { - if (itemElements.length === 1) { - item.classList.add("protyle-breadcrumb__text--ellipsis"); - jump = true; - return true; - } - if (!item.classList.contains("protyle-breadcrumb__text--ellipsis")) { - item.classList.add("protyle-breadcrumb__text--ellipsis"); - return true; - } - if (index === itemElements.length - 1 && item.classList.contains("protyle-breadcrumb__text--ellipsis")) { - jump = true; + if (index > 0) { + if (!item.classList.contains("protyle-breadcrumb__text--ellipsis")) { + item.classList.add("protyle-breadcrumb__text--ellipsis"); + return true; + } + if (index === itemElements.length - 1 && item.classList.contains("protyle-breadcrumb__text--ellipsis")) { + jump = true; + } } }); } this.element.classList.add("protyle-breadcrumb__bar--nowrap"); if (this.element.lastElementChild) { - this.element.scrollLeft = (this.element.lastElementChild as HTMLElement).offsetLeft - this.element.clientWidth - 8; + this.element.scrollLeft = (this.element.lastElementChild as HTMLElement).offsetLeft - this.element.clientWidth + 14; } }); }