diff options
-rw-r--r-- | ui.js | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/ui.js b/ui.js index 378cd77..7cc55e2 100644 --- a/ui.js +++ b/ui.js @@ -2068,8 +2068,21 @@ class PathItemElement extends FocusElement { } fixLayout() { - this.button.fixLayout() + const text = this.item.name || '(Unnamed)' + + const maxWidth = this.parent ? this.parent.contentW : Infinity this.arrowLabel.fixLayout() + + const maxButtonWidth = maxWidth - this.arrowLabel.w + + if (text.length > maxButtonWidth) { + this.button.text = unic.ELLIPSIS + text.slice(-(maxButtonWidth - 1)) + } else { + this.button.text = text + } + + this.button.fixLayout() + this.w = this.button.w + this.arrowLabel.w this.button.x = this.arrowLabel.right this.h = 1 |